Importing to IntelliJ - Error package org.springframework.boot does not exist

Viewed 32024

Dear Stackoverflow Community, I have the following problem with my spring boot starter application. I imported the starter project as a new maven project into IntelliJ. But IntelliJ does not find the dependencies I specified in the pom.

Image of my Application Class:

If I try to run the project I get the following error message.

Image of the Error Message:

I already tried everything from re-installing IntelliJ to re-importing the project or redownloading the dependencies. I simply dont know why IntelliJ doesn´t find the dependencies.

My pom.xml looks as following

Image of my pom.xml:

The first time I tried to edit the pom.xml it said to me "this file does not belong to the project". Maybe this might be one reason.

Running the whole thing with 'mvn install' or 'mvn clean verify' works.

8 Answers

Try this and then build: mvn -U idea:idea

Had the same problem. I have tried everything: invalidating cache, deleting the whole .m2 folder, changing settings, reloding the project, nothing helped.

The solution for me was to delete the .iml files which are IntelliJ module files used for keeping module configuration. After reopening the project it worked.

The idea was not mine, I found the hint here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/203365204--package-does-not-exist-error-despite-autocomplete-being-aware-of-them

in my case changed JDK version in Maven importer from JDK 11 to my local JDK version 1.8

enter image description here

Here is how my IntelliJ settings for spring boot application looks like

Click open -> browse your workspace -> and select POM.xml file Click open -> browse your workspace -> and select POM.xml file

Check this in your intelliJ settings Check this in your intelliJ settings

Do this too [Settings --> Maven --> Importing]

enter image description here

Sometimes your workspace could get corrupted. In my case, I tried to Reload the project and it worked

enter image description here

I just had the same issue. My solution was to remove all dependencies from the pom, reload via maven -> Reload All Maven Projects. Run mvn compile. Add dependencies back to the pom, maven -> Reload All Maven Projects. Run mvn compile. Now the Intellij build works.

You need to change Maven's JDK for importing option from Project JDK to the Path variable for Java on your machine.

You can get to this by going to Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing. Scroll down to the bottom and look for JDK for importing:. Select from the list the path variable for JAVA.

Above image shows how to change the JDK for importing with Maven.

For Windows users, JAVA_HOME should be an option in the drop-down list.

Follow these steps, your problem should be solved. You just need to add Spring-framework-starter-web and Spring-framework-starter-tester from your pom.xml file.

  1. Got to generate(ALT+Insert)
  2. Add dependencies
  3. Search "springframwork"
  4. Add...

Here is the link

Related