【发布时间】:2020-05-15 04:06:52
【问题描述】:
我今天做了一个简单的应用程序,运行时出现了一些错误。我昨天做了另一个与这个非常相似的应用程序,它运行良好,但现在也坏了
我收到以下错误:
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
这是我的 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>
我试过了:
- 重新导入所有 Maven 项目
- 为所有项目生成源代码并更新所有文件夹
- 使用 Spring initalizer 创建新项目
- 检查 settings.xml 的设置路径
- 删除 .m2 文件夹
- 使缓存失效并重新启动
- 使用自动导入重新打开项目
- 删除/更改导入的 VM 选项
- 强制 Intellij 重新读取所有 maven 依赖项
- 确认依赖项在模块中
- 更新 Maven 存储库
- 许多不同的 pom.xml 配置
- 克隆和构建一个已知有效的项目
- 更改 Maven 的默认可执行文件
- 完全关闭自动同步
- 重新安装 Intellij
还有其他想法吗?
【问题讨论】:
-
youtrack.jetbrains.com/issue/… 有帮助吗? IntelliJ IDEA 2020.1 和 2020.1.1 版本受到特定于 Maven 项目的错误的影响,其中 IDE 的构建填充失败。您还可以使用来自 jetbrains.com/idea/download/previous.html 的 2019.3.x 版本作为解决方法。
-
添加 path.macros.xml 有效!谢谢!
标签: java spring spring-boot maven intellij-idea