Reputation: 167
I made a simple application today that gives me a few errors when I run. I made another application very similar to this one yesterday which was working fine but is now broke as well
I am getting these errors:
Error:(4, 32) java: package org.springframework.boot does not exist
Error:(5, 46) java: package org.springframework.boot.autoconfigure does not exist
Error:(6, 35) java: package org.springframework.context does not exist
Error:(9, 2) java: cannot find symbol
symbol: class SpringBootApplication
Error:(13, 17) java: cannot find symbol
symbol: class ApplicationContext
location: class com.example.dependencyinjection.DependencyInjectionApplication
Error:(13, 42) java: cannot find symbol
symbol: variable SpringApplication
location: class com.example.dependencyinjection.DependencyInjectionApplication
Error:(3, 38) java: package org.springframework.stereotype does not exist
Error:(5, 2) java: cannot find symbol
symbol: class Controller
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>dependency-injection</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>dependency-injection</name>
<description>Example project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I have tried:
Any other ideas?
Upvotes: 8
Views: 31956
Reputation: 740
This worked for me
Delete the .idea folder from your workspace
do invalidate cache
Go to File -> Project Structure
Under Project -> Check SDK, Language Level
Under Modules -> Mark respective directories as Source, Resources and Tests
Under SDK -> Select your required JDK version
Click Apply
Perform clean install to delete Target folder
And you are good to go.
Upvotes: 0
Reputation: 164
I followed these steps and my project built successfully.
mvn clean
Upvotes: 2
Reputation: 1
Well, I was able to solve the issue by simply restarting my laptop having all required dependencies and JDK setup.
Upvotes: 0
Reputation: 1503
in my case have changed Maven import JDK version.
In latest version in intellij its pointing to JDK11. then changes to my internal JDK version resolved issue
Upvotes: 3
Reputation: 402493
There is a known bug in IntelliJ IDEA 2020.1 and 2020.1.1 versions (will be fixed in 2020.1.2) where Maven dependencies are not found by the compiler because the path macros are not resolved properly.
You can use a workaround until the fix is released or downgrade to 2019.3.x version.
The workaround is to override the default setting for Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Local repository (set it to some other value different from default).
Or else make sure the path.macros.xml
file exists in <IDE config>
/options
directory with the following content:
<application>
<component name="PathMacrosImpl">
<macro name="KOTLIN_BUNDLED" value="<path to IDE installation>\plugins\Kotlin\kotlinc" />
<macro name="MAVEN_REPOSITORY" value="<path to>/.m2/repository" />
</component>
</application>
Where the <path to>/.m2/repository
- is the path to your local Maven repository and the <path to IDE installation>
- the path to IDE installation home.
Upvotes: 7
Reputation: 1316
Add spring-boot-starter-web dependency to your POM
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Upvotes: 1
Reputation: 1060
You don't need the spring-boot
dependency in your pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
Upvotes: 0