Error: java: package org.springframework.boot does not exist

我今天做了一个简单的应用程序,运行时出现了一些错误。我昨天做了一个与此非常相似的应用程序,本来运行良好,但现在也出错了

我得到了这些错误。

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文件夹
  • 使缓存无效并重新启动
  • 在自动导入的情况下重新打开项目
  • 删除/改变导入的虚拟机选项
  • 强制Intellij重新读取所有的maven依赖项
  • 确认模块中是否有依赖项
  • 更新Maven资源库
  • 许多不同的pom.xml配置
  • 克隆并构建一个已知可运行的项目
  • 改变Maven的默认可执行文件
  • 将自动同步完全关闭
  • 重新安装Intellij

还有其他办法吗?


StackOverflow:spring - Error: java: package org.springframework.boot does not exist - Stack Overflow