Question

[Solved] IntelliJ: Cannot resolve symbol ‘springframework’

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…

Enquirer: Antoine

||

Solution #1:

enter image description here

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

Respondent: Vinayak Shedgeri

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’).

Respondent: MrBlueSky

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
Respondent: SaravanaKumar KKB

Solution #4:

In my case, I was behind Office proxy and that why MAVEN was unable to download the required dependencies on its own !

After switching the network and executing below command : mvn clean install -U, it worked !!

Respondent: Aditya Goel

Solution #5:

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

Respondent: Rahman786

Solution #6:

Please check if you have configured Maven Settings.

IntelliJ (File > Settings > Build,Execution,Deployment > Build Tools > Maven )

Maven home path : C:/Program Files/apache-maven-3.6.0

It resolved my error.

Respondent: Kaushal Jhawar

Solution #7:

Check if

/Users/<userName>/.m2/

location has settings.xml and toolchains.xml.
I think toolchains might not be necessary but settings.xml is required.
Instructions for creating settings.xml can be found here – https://maven.apache.org/settings.html

My issue was resolved after adding settigs.xml and toolchains.xml to above mentioned location and restarting the IDE.

Respondent: jaySingh

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy