Jan Kreischer
Jan Kreischer

Reputation: 771

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

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.

Upvotes: 12

Views: 60129

Answers (15)

Manas Vyas
Manas Vyas

Reputation: 1

I also had the same issue. Just check:

  • whether your maven is correctly installed
  • that you have set its bin folder in the environment variable,
  • that you have jdk installed.

Then in settings-> build, execution, deployment->build tools-> maven -> select the maven home path to bundled maven 3.

Then reload all from disk or press Ctrl+Alt+y. My issue was resolved by the reloading.

Upvotes: 0

Sagar Hiremath
Sagar Hiremath

Reputation: 11

For me this method worked, seems dependencies are not downloaded due to wrong Maven home path.

settings >> Build, Execution, Deployment >> Build Tools >> Maven >> change maven home path from "use maven wrapper" to Bundled(Maven 3)

Upvotes: 1

SaiKrishna Gollapally
SaiKrishna Gollapally

Reputation: 11

I had same issue. I was using IntelliJ IDEA. In my case I deleted .idea folder and re-build the project then it worked well.

Upvotes: 1

noorullahkarimi
noorullahkarimi

Reputation: 111

I have the same error. I removed all folder and file in this path below:

C:\Users\Lenovo.m2\repository

I opend the intelij IDE and opened the maven:

View -> Tool Windows ->Maven

and clicked on the "Reload All Maven Project". it downloaded the dependencies and run the project again. check before the path below:

C:\Users\Lenovo.m2\repository

it should download all the dependencies.

I hope it is helpfull.

Upvotes: 0

Zamokuhle Khumalo
Zamokuhle Khumalo

Reputation: 1

I had the same issue , only to find out I made a very careless mistake of having 2 versions of IntelliJ.

I uninstalled all of them and did a new installation, now everything works.

Upvotes: 0

Daphne
Daphne

Reputation: 1

For my case, had to change the maven importing settings from the JRE path to the JDK path on my local machine

Upvotes: 0

Pooja
Pooja

Reputation: 1

In my case, adding the project as maven project helped .

Upvotes: 0

Enock Kalonji
Enock Kalonji

Reputation: 11

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

Upvotes: 1

Khalil
Khalil

Reputation: 331

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.

Upvotes: 0

Dan Poulos
Dan Poulos

Reputation: 51

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.

Upvotes: 1

Anupama Boorlagadda
Anupama Boorlagadda

Reputation: 1288

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

enter image description here

Upvotes: 6

Márk Farkas
Márk Farkas

Reputation: 1546

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

Upvotes: 18

Anand saga
Anand saga

Reputation: 1503

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

enter image description here

Upvotes: 2

wshow
wshow

Reputation: 151

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

Upvotes: 15

smilyface
smilyface

Reputation: 5513

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

Upvotes: 1

Related Questions