0
votes

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

1
What steps did you take to "import" it? - chrylis -cautiouslyoptimistic-
What intellij and gradle version do you use. You should try to delegate build and run actions to gradle. - Peter
I imported an exiting project (spring boot example, gs-rest-service) using gradle. I used gradle wrapper. - porswengr
Thank 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

1 Answers

1
votes

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.