java – 无法访问org.springframework.context.ConfigurableApplicationContext类文件

我是春季启动的新手,在尝试使用
spring初始化程序在intellij中构建我的第一个
Spring启动项目(Maven)时,我在创建项目后运行项目时遇到此错误:

cannot access org.springframework.context.ConfigurableApplicationContext
class file for org.springframework.context.ConfigurableApplicationContext not found

我遵循了许多教程,但每次收到此错误时,如何解决此问题?

我的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 
      http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.boot</groupId>
    <artifactId>das-boot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>First spring boot app</name>
    <description>project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>    

最佳答案 我能够通过以下步骤解决它:

>文件 – >使缓存无效并重新启动
>文件 – >新 – >来自现有来源的项目
>选择pom.xml文件(不是整个项目目录)
加载项目.项目将自动设置.

点赞