1

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

asked Apr 27, 2019 at 1:26
4
  • 1
    What steps did you take to "import" it? Commented Apr 27, 2019 at 1:33
  • 1
    What intellij and gradle version do you use. You should try to delegate build and run actions to gradle. Commented Apr 27, 2019 at 14:48
  • I imported an exiting project (spring boot example, gs-rest-service) using gradle. I used gradle wrapper. Commented Apr 27, 2019 at 14:58
  • 1
    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. Commented Apr 27, 2019 at 15:18

1 Answer 1

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.

answered Apr 27, 2019 at 15:20
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.