Getting a classnotfound exception when trying to run a spring boot example from intelliJ.
I imported one of the 'Getting started guides' from spring.io, specially https://github.com/spring-guides/gs-rest-service.git project into IntelliJ.
I can successfully, build and run the project using ./gradle build and ./gradle bootRun
Now I want to run or debug from IntelliJ,I get following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
I am trying to run/debug after creating a simple configuration but it throws this exception. How does intelliJ resolve the dependencies. This works from command line when I use gradle bootRun.
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
-
1What steps did you take to "import" it?chrylis -cautiouslyoptimistic-– chrylis -cautiouslyoptimistic-2019年04月27日 01:33:04 +00:00Commented Apr 27, 2019 at 1:33
-
1What intellij and gradle version do you use. You should try to delegate build and run actions to gradle.Peter– Peter2019年04月27日 14:48:10 +00:00Commented Apr 27, 2019 at 14:48
-
I imported an exiting project (spring boot example, gs-rest-service) using gradle. I used gradle wrapper.porswengr– porswengr2019年04月27日 14:58:44 +00:00Commented Apr 27, 2019 at 14:58
-
1Thank you chrylis and peter. I was able to get around this issue by adding a new gradle configuration with the 'bootRun' task. Initially I was using a spring boot configuration.porswengr– porswengr2019年04月27日 15:18:05 +00:00Commented Apr 27, 2019 at 15:18
1 Answer 1
I was able to get past this error by using a new gradle configuration with the 'bootRun' task (in the Run/debug configurations dialog) Initially I had created a spring boot configuration.
Comments
Explore related questions
See similar questions with these tags.