• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Cannot run simple Spring Boot application

 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing my very first Spring Boot application. It's very simple: Print "Hello World" to the terminal window, nothing more.  

This is the code:



However, upon running it, I get this:


Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-06-27T16:28:16.031-04:00 ERROR 19860 --- [mysb] [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

   org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer.<init>(ContentNegotiationConfigurer.java:109)

The following method did not exist:

   'void org.springframework.web.accept.ContentNegotiationManagerFactoryBean.setServletContext(jakarta.servlet.ServletContext)'

The calling method's class, org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer, was loaded from the following location:

   jar:file:/C:/Users/me/.m2/repository/org/springframework/spring-webmvc/6.2.8/spring-webmvc-6.2.8.jar!/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.class

The called method's class, org.springframework.web.accept.ContentNegotiationManagerFactoryBean, is available from the following locations:

   jar:file:/C:/Users/me/.m2/repository/org/springframework/spring-web/7.0.0-M6/spring-web-7.0.0-M6.jar!/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.class

The called method's class hierarchy was loaded from the following locations:

   org.springframework.web.accept.ContentNegotiationManagerFactoryBean: file:/C:/Users/me/.m2/repository/org/springframework/spring-web/7.0.0-M6/spring-web-7.0.0-M6.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer and org.springframework.web.accept.ContentNegotiationManagerFactoryBean


Process finished with exit code 0



I thought it might be a version issue, as I am using Maven with dependencies, but changing the version to a lower version number has no effect; the error is the same.

I don't know what to do, and this is more frustrating as it directly comes from an online tutorial.

Thanks
 
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't done Spring Boot with this particular setup, but there are a few things I'd check.

1. You should have Spring Web enabled in your Maven POM. This will automatically be done if you generated your project with the Initiizr (https://start.spring.io) and selected the Spring Web dependency option. You should not have attempted to manually add any Spring Web dependencies (you might get a version conflict).

2. I'm not sure that your app should also be your URL handler.  In a JSF Spring Boot app, the SpringBootApplication class only does basic setup and hooks into Spring Security. All of the application code itself was for me in standard application code classes. In the case of Spring Web, therefore, I'd expect that your actual URL processor would be an independent ReST Controller class that would look exactly like how you'd code it for a regular Spring webapp (without Spring Boot).
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if Initizr comes with IntellliJ, which is what I'm using to build everything
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if Initizr comes with IntellliJ, which is what I'm using to build everything
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring Boot Initilizr is a web site (start.spring.io). You fill in the form and it generates a complete Spring Boot project. You download it and import it into IntelliJ (or Eclipse, or whatever).

Helpful Hint: for a Maven project, run the goal "mvn intellij:intellij" and it will generate the Intellij metadata files so you don't have to manually set up stuff like project directory paths and the like.
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Spring Boot Initilizr is a web site (start.spring.io). You fill in the form and it generates a complete Spring Boot project. You download it and import it into IntelliJ (or Eclipse, or whatever).

Helpful Hint: for a Maven project, run the goal "mvn intellij:intellij" and it will generate the Intellij metadata files so you don't have to manually set up stuff like project directory paths and the like.



working on the first part, but I don't understand the second part. How do I do that in IntelliJ? I am very brand new to IntelliJ

Thanks
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, spring-boot-starter-web-services and spring-session-core fails in IntelliJ in spite of invalidating cache over and over; it keeps saying "versions not found", even tnough I am including the URL to the Maven repository to obtain them

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web-services

https://mvnrepository.com/artifact/org.springframework.session/spring-session-core
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's start from the command line.

First, generate/download your Spring Boot app using initializr. I'm assuming you chose Maven to build the app and have Maven installed.

Now cd into the project directory and run "mvn spring-boot:run". That should build and run your prototype app. Probably displays a "hello world" page or something.

Now that you've built the app from the command line, run "mvn intellij:intellij". That will add IntelliJ metadata files to your Spring Boot project so that IntelliJ will know where your source files and other project resources are located.

At this point, launch IntelliJ and tell it to import your project. That should be all you need to get up and ready to develop your actual project code.
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Let's start from the command line.

First, generate/download your Spring Boot app using initializr. I'm assuming you chose Maven to build the app and have Maven installed.

Now cd into the project directory and run "mvn spring-boot:run". That should build and run your prototype app. Probably displays a "hello world" page or something.

Now that you've built the app from the command line, run "mvn intellij:intellij". That will add IntelliJ metadata files to your Spring Boot project so that IntelliJ will know where your source files and other project resources are located.

At this point, launch IntelliJ and tell it to import your project. That should be all you need to get up and ready to develop your actual project code.



I'll remember that next time. What I wound up doing was the nuclear option: destroyed the project and successfully recreated it.  The Spring Boot application is now recognized as a Jav class, all of my Maven dependencies are there, the Project SDK points to C:\Program Files\OpenJDK and compiles just fine, and I am back to my original error involving AJPNioProtocol, but at least it is capable of running now
 
Saloon Keeper
Posts: 279
7
Android Python Oracle Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Let's start from the command line.

First, generate/download your Spring Boot app using initializr. I'm assuming you chose Maven to build the app and have Maven installed.

Now cd into the project directory and run "mvn spring-boot:run". That should build and run your prototype app. Probably displays a "hello world" page or something.

Now that you've built the app from the command line, run "mvn intellij:intellij". That will add IntelliJ metadata files to your Spring Boot project so that IntelliJ will know where your source files and other project resources are located.

At this point, launch IntelliJ and tell it to import your project. That should be all you need to get up and ready to develop your actual project code.



Yes, that's to way to go both for IntellJ or Eclipse. The project should start with a Maven setup.

Only one comment: I cannot remember that I ever used  "mvn intellij:intellij". Until now I created Maven projects in IntellJ manually:

- Select "Open -> Project from existing sources" from menu
- Navigate to the root folder of the Maven project
- Accept creation of project

Does the integration provide anything in addition to this manual approach?
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I have a new and very weird problem:

I tried to fix the issue with secretRequired="true" by adding secretRequired="false" to my local project in Tomcat's server.xml and running the Tomcat9 application, then invalidating cache and restarting IntelliJ.

Upon running my Spring Boot Application class this time I get:


java: cannot access org.springframework.beans.factory.BeanRegistrar
class file for org.springframework.com.beans.factory.BeanRegistrar not found



This makes no sense to me, because I included spring-beans inside my pom.xml successfully
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring Boot has an embedded Tomcat server and it shouldn't be using server.xml. Tomcat can be embedded by instantiating the root Tomcat JavaBean and injecting properties into it. Which is basically what the stand-alone Tomcat launcher does after it digests server.xml.

That's assuming you set up to run Spring Boot as a JAR. If you set it up to run as a WAR, then you'd deploy that WAR into your own instance of Tomcat (or in IntelliJ's).

Or, in IntelliJ, if you set up to build a JAR, run/debug your Spring Boot app as a regular Java app, NOT as a webapp. Only run it as a webapp if you built a WAR.

You should not have to be adding any Spring dependencies to your POM at this level.
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Spring Boot has an embedded Tomcat server and it shouldn't be using server.xml. Tomcat can be embedded by instantiating the root Tomcat JavaBean and injecting properties into it. Which is basically what the stand-alone Tomcat launcher does after it digests server.xml.

That's assuming you set up to run Spring Boot as a JAR. If you set it up to run as a WAR, then you'd deploy that WAR into your own instance of Tomcat (or in IntelliJ's).

Or, in IntelliJ, if you set up to build a JAR, run/debug your Spring Boot app as a regular Java app, NOT as a webapp. Only run it as a webapp if you built a WAR.

You should not have to be adding any Spring dependencies to your POM at this level.



I am running it as a Java app in IntelliJ, and that's the error I'm getting every time now. I don't know how to get past this considering that IntelliJ should have an in-built Tomcat server, but I can't even get to it at this point. I don't know what to do
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured out to change the code



However, now I get this:


***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

   org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer.<init>(ContentNegotiationConfigurer.java:109)

The following method did not exist:

   'void org.springframework.web.accept.ContentNegotiationManagerFactoryBean.setServletContext(jakarta.servlet.ServletContext)'

The calling method's class, org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer, was loaded from the following location:

   jar:file:/C:/Users/PhillipPowell/.m2/repository/org/springframework/spring-webmvc/6.2.8/spring-webmvc-6.2.8.jar!/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.class

The called method's class, org.springframework.web.accept.ContentNegotiationManagerFactoryBean, is available from the following locations:

   jar:file:/C:/Users/PhillipPowell/.m2/repository/org/springframework/spring-web/7.0.0-M6/spring-web-7.0.0-M6.jar!/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.class

The called method's class hierarchy was loaded from the following locations:

   org.springframework.web.accept.ContentNegotiationManagerFactoryBean: file:/C:/Users/PhillipPowell/.m2/repository/org/springframework/spring-web/7.0.0-M6/spring-web-7.0.0-M6.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer and org.springframework.web.accept.ContentNegotiationManagerFactoryBean


Process finished with exit code 0

 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added the dependency of spring-webmvc  (version 7.0.0-M6) to go weith spring-web (version 7.0.0-M6) and now I get this:


Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-06-30T11:44:58.761-04:00 ERROR 24588 --- [fvaplocal] [  restartedMain] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.defaultViewResolver
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:99) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:186) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:147) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:123) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:430) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:290) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609) ~[spring-context-6.2.8.jar:6.2.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361) ~[spring-boot-3.5.3.jar:3.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350) ~[spring-boot-3.5.3.jar:3.5.3]
at gov.fvap.fvaplocal.FvapLocalApplication.main(FvapLocalApplication.java:91) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:569) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.5.3.jar:3.5.3]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@60e53b93]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-6.2.8.jar:6.2.8]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:360) ~[spring-core-6.2.8.jar:6.2.8]
at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:417) ~[spring-core-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$1(AbstractAutowireCapableBeanFactory.java:757) ~[spring-beans-6.2.8.jar:6.2.8]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1740) ~[na:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:756) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:689) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:660) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1716) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:639) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:611) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:596) ~[spring-beans-6.2.8.jar:6.2.8]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanDefinitionsForType(OnBeanCondition.java:322) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanDefinitionsForType(OnBeanCondition.java:314) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:214) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.evaluateConditionalOnMissingBean(OnBeanCondition.java:197) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:144) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-3.5.3.jar:3.5.3]
... 22 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/ThemeResolver
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465) ~[spring-core-6.2.8.jar:6.2.8]
... 39 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.ThemeResolver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
... 43 common frames omitted

 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally solved it simply by changing AnnotationConfigApplicationContext to AnnotationConfigWebApplicationContext, then I did away with the hard-coded Jakarta-based servlet I created and put a simple HTML file in /resources/static, downgraded both spring-web and spring-webmvc to 6.2.7, added spring-context v6.2.7, got rid of the entire ServletRegistrationBean block and just let the Spring Boot app create its own DispatcherServlet, which pulled up /resources/static/index.html and voila, an HTML page in my browser! It was easier than I thought it would be! Thanks
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So:

A) You "improved" the project by manually changing what the Initializr generated. It's better to simply re-generate the project.

B) You added manual stuff that conflicted with what Spring was already providing.

Moral of story: Spring Boot is intended to build stuff that runs out-of-the-box. Not have its innards fiddled with.

Finally:

C) If an annotation gives an error, check the JavaDocs to see what version of Spring/Spring Boot the annotation applies to and either re-generate the project to match the annotation or change the annotation to match the version of Spring Boot that you have generated.
 
Author
Posts: 52
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at the Spring Boot tutorials?
They offer two learning paths. One is to follow along and type in the code and the other is to use a complete example.

Getting Started | Building an Application with Spring Boot https://spring.io/guides/gs/spring-boot/
 
Phillip Powell
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephen Morris wrote:Have you looked at the Spring Boot tutorials?
They offer two learning paths. One is to follow along and type in the code and the other is to use a complete example.

Getting Started | Building an Application with Spring Boot https://spring.io/guides/gs/spring-boot/



Yes. I even copied the code verbatim to what I found in several different Spring tutorials, and I still had to "rearrange the innards" to get the application to work. I went to start.spring.io and had it auto-build an application; it too failed in IntelliJ until I manually added the ability to open up a Tomcat server. At this point I'm pursuing a different approach altogether
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You did something wrong then.

When you use Initializr to generate a Spring Boot JAR, the resulting code doesn't want you to "open up a Tomcat" because it launches its own internal Tomcat.

Note that since one and only one process can listen on (own) a TCP port, if you're running a Spring Boot app and IntelliJ is also running Tomcat, one of them won't work. Both Tomcats will execute but only one will be able to receive web requests. Tomcat will not outright fail because it's a collection of processes and the non-conflicting processes will be unaffected, but you won't enjoy the results.

Again, Spring Boot is intended to come up and running out of the box. If you have to tweak it to make it work, you're doing it wrong.
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roland Mueller wrote:
Does the integration provide anything in addition to this manual approach?


It creates the metadata files used by IntelliJ. If memory serves and they haven't changed since I last looked closely (a LONG time ago!). IntelliJ had 3 primary XML metadata files. One was to define the project, one to define the current user's GUI state, and I forget the use of the third.

In Eclipse, a blank project won't know Maven's quirks regarding location of source, class-building and target directories so the mvn eclipse:eclipse goal sets up the project accordingly. It's possible that at this point IntelliJ doesn't need to be explicitly told when importing, since IntelliJ has always been more helpful for common everyday projects whereas Eclipse targeted a more general environment. But it can't hurt to run the intellij goal before importing, regardless.
 
Roland Mueller
Saloon Keeper
Posts: 279
7
Android Python Oracle Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:

Roland Mueller wrote:
Does the integration provide anything in addition to this manual approach?


It creates the metadata files used by IntelliJ. If memory serves and they haven't changed since I last looked closely (a LONG time ago!). IntelliJ had 3 primary XML metadata files. One was to define the project, one to define the current user's GUI state, and I forget the use of the third.



Yes, I know that both approaches for IntelliJ create IDE stuff in the .idea subdir.

My question was whether there is an advantage to use first "mvn intellij:intellij" and then open the project in the IDE (1st approach), instead of simply opening the directory containing the Maven project as project from inside IntelliJ (2nd approach).

In latter way I most often start IDE projects by first create|download|clone a Maven project, and then opening it manually.
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, to repeat myself, the metadata files define the project configuration and the user's edit state - what project/files are open for editing, for example. They retain this information when the IDE is not running and are read when you start up IntelliJ to establish/resume the project environment.

It's important to note that there is no such thing as a universal Java project structure defined as part of the JLS/runtime specs. In fact, early Java IDEs (such as Borland's Visual Cafe) often had their own unique ideas on where to put stuff. Maven defaults to /src/main/java for the project source code, but that can be overridden (and you won't enjoy if if you do). Ant projects are entirely free-form. Look at the source code for Tomcat, for example. Tomcat's source directory is simply /java.

The Intelllij project file, therefore tells IntelliJ where the source and compile directories are, and while these days it MIGHT be able to deduce that by reading the POM file (if it's a Maven project), originally IntelliJ would compile to a default location, not the /target directory unless informed otherwise. You would end up with 2 compiled copies, one in /target, one in IntelliJ's default compile target location. Been there/did that. Typically, open-source Maven-based projects don't keep either the project or user metadata files in their master archives, and in fact, archiving the user metadata file would cause multiple developers to step all over each other.

So, in short, the best approach is to run the mvn intellij goal and THEN import the project. An alternative would be to import the project, shut down intellij, run mvn intellij, then restart intellij, where it will now pick up on the generated information. Running mvn intellij on a project that's currently open in Intellij would likely result in problems.
 
Roland Mueller
Saloon Keeper
Posts: 279
7
Android Python Oracle Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My point is that IntelliJ not just retrieves information for a pom and then uses its own build system.
It really works together with Maven.  

That means you cannot only use existing Maven projects but also

- create Maven projects from scratch,
- edit the pom.xml adding new dependencies or adding plugin configuration, properties etc.
- you can either run Maven goals from inside the IDE or from command line



More:
More https://www.jetbrains.com/help/idea/maven-support.html

The picture shows the dialog that opens when creating a new project:
 
Tim Holloway
Saloon Keeper
Posts: 28822
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is not unique to IntelliJ, Eclipse also has those capabilities.

However, they are extensions to the IDE, not part of the core IDE itself. Maven is actually run as a Java application in the IDE.

IntelliJ isn't my home IDE and I've only been using it lately in its manifestation as Android Studio. I do see some differences. For one thing, there's no "New Maven Project" option, and in fact, the only "new anything" projects are Android-based, they expect Gradle as their build tool and Kotlin as their preferred language. It would appear that the Maven plugin isn't even installed in this version.

The metadata has changed quite a bit, though. In a sample Android project only the workspace.xml file remains intact, I think, and I'm not sure that the config files were originally in their own directory last time I used IntelliJ at work.

So at this point, all I can say is that if you can import a POM-based (Maven) project and not have to manually set source and compile directories, then IntelliJ must have added some more intelligence and the maven intellij is either no longer needed or possibly invoked internally automatically. As I said earlier, while it's not as capable for the really gnarly stuff, IntelliJ excels at the everyday functions that most application developers use.
 
get schwifty. tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic