IntelliJ: Cannot resolve symbol 'springframework'

96,815

Solution 1

enter image description here

Click on refresh button .Maven may not be able to sync properly

Solution 2

I had the same problem, and this is how it worked for me:

On the source root directory -> right click -> Add Framework Support.

A window will open with different categories, such as Java EE, JBoss etc. Go to 'Spring' category. Then, download the pack of libraries that you need (I used 'Spring MVC').

Solution 3

Add dependency for springframework in pom.xml and run below command from directory where pom.xml exist.

mvn clean install -U

Above command will forcefully download the dependencies.

if you are behind proxy then try below command

mvn clean install -DproxySet=true -DproxyHost=www-proxy.us.com -DproxyPort=80

Solution 4

In my case triggering an Invalidate Caches/Restart helped IntelliJ now find those dependencies.

The Invalidate Caches/Restart option

Following what Mr. BlueSky told in his answer here, I could get the dependencies downloaded. Actually, the answer by Vinayak Shedgeri should have helped too. For those whom it didn't, you could try the invalidate cache/restart.

P. S.: And going by what could have caused this behavior, you could very well try something as simple as relaunching IntelliJ first. Just a guess.

Solution 5

Project root directory -> right click -> Add Framework Support --> Maven or Gradle --> Click Ok

Share:
96,815

Related videos on Youtube

Antoine Grenard
Author by

Antoine Grenard

Updated on May 12, 2022

Comments

  • Antoine Grenard
    Antoine Grenard about 2 years

    I'm trying to start my first project with Spring. I use IntelliJ idea and I'm kind of new to it too. But anyways, I followed the step written on the Jetbrains website and I don't know what I have done wrong, but I got a lot of errors on the first to files that are created by default.

    BloomBookingApplcation.java

    package com.bloombooking;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class BloomBookingApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(BloomBookingApplication.class, args);
        }
    }
    
    Error:(3, 12) Cannot resolve symbol 'springframework'
    Error:(4, 12) Cannot resolve symbol 'springframework'
    Error:(6, 2) Cannot resolve symbol 'SpringBootApplication'
    Warning:(7, 1) Access can be packageLocal
    Error:(9, 26) Cannot resolve symbol 'String'
    Error:(10, 3) Cannot resolve symbol 'SpringApplication'
    

    Maybe I'm stupid but I don't know which step I've missed...

    How can I fix this?

    I have found the way to add spring with the quickfix button.

    But now I have got new errors I don't understand why... I should maybe download it directly and put the libraries one by one maybe?

    Error:(3, 28) Cannot resolve symbol 'boot'
    Error:(4, 28) Cannot resolve symbol 'boot'
    Error:(6, 2) Cannot resolve symbol 'SpringBootApplication'
    Warning:(7, 1) Access can be packageLocal
    Error:(9, 26) Cannot resolve symbol 'String'
    Error:(10, 3) Cannot resolve symbol 'SpringApplication'
    

    Or maybe it's my IntelliJ idea which isn't configured right since I don't have any completion anywhere and I can't create packages...

    • Andreas
      Andreas about 8 years
      You didn't add the Spring .jar files to the classpath?
    • Antoine Grenard
      Antoine Grenard about 8 years
      Arf ! I didn't knew it wouldn't be done automatically .. I've searched and found how to do it thx to you :)
    • OneCricketeer
      OneCricketeer about 8 years
      "Cannot resolve symbol 'String'" - looks like your Java installation is broken or you have not configured the JDK in Intellij
    • Antoine Grenard
      Antoine Grenard about 8 years
      Mmmhh it is kind of strange cause when i go into project structure the jdk 1.8 appear ..
    • Antoine Grenard
      Antoine Grenard about 8 years
      My JDK Wasn't configured as it should have been i've found how to do it properly here : stackoverflow.com/questions/4618794/…
    • Antoine Grenard
      Antoine Grenard about 8 years
      After that i've decided to delete all and redo it again and it work like magic :)
    • Roman C
      Roman C about 8 years
      This question does not appear to be about programming within the scope defined in the help center.
    • Mohamed Bouguerra
      Mohamed Bouguerra over 6 years
      Your are missing some dependencies. Try this ! stackoverflow.com/questions/35293116/…
  • Scott Greenup
    Scott Greenup about 5 years
    This worked perfectly for me. I had created the project based on a new Maven project, and while I could use mvn on the CLI, Intellij was showing me the errors that Atoine had.
  • KansaiRobot
    KansaiRobot over 4 years
    there is no spring MVC. Only Groovy
  • KansaiRobot
    KansaiRobot over 4 years
    Did this,. Nothing changed
  • KansaiRobot
    KansaiRobot over 4 years
    Non-resolvable parent POM for the SNAPSHOT
  • Harsha Vardhan Chakka
    Harsha Vardhan Chakka almost 4 years
    Could not find "spring" in the list of framework support
  • shanavascet
    shanavascet over 3 years
    I have faced the same issue as the OP. I had started the project from the scratch using IntelliJ IDE and spring initializer. The maven wasn't installed separately even though it was available as part of the project. I installed maven separately from this link maven.apache.org/download.cgi. Run the above command and it worked for me.
  • Dhannanjai
    Dhannanjai over 3 years
    You will find "Spring" only in the Intellij Ultimate Edition. You can go with "Application" in the configuration.
  • Sahin
    Sahin about 3 years
    I couldnt find it