无法解析org.springframework.context.ConfigurableApplicationContext类型。它是从所需的.class文件间接引用的 [英] The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files

查看:651
本文介绍了无法解析org.springframework.context.ConfigurableApplicationContext类型。它是从所需的.class文件间接引用的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 spring.io 上关注该教程,以构建一个弹簧应用程序春天启动。

I am following the tutorial at spring.io to build a spring app using spring boot.

我可以让程序在一台计算机上完美运行。
当我尝试使用另一台计算机时出现以下错误

I can get the program to run perfectly on one computer. When I try on a different computer I get the following error


org.springframework.context.ConfigurableApplicationContext类型无法解析。它是从所需的.class文件间接引用的。

The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files

我试过删除并添加我的JRE系统库(JDK 1.8),以及使用maven清理和更新项目,甚至删除并重新导入整个项目。所有这些方法都没有成功。

I have tried deleting and adding my JRE Systems Library (JDK 1.8), as well as cleaning and updating the project using maven, and even deleting and re-importing the entire project. All of these methods have shown no success.

我的pom文件是

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
  </parent>

  <groupId>test.api</groupId>
  <artifactId>api.test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>api.test Maven Webapp</name>
  <url>http://maven.apache.org</url>

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

   <properties>
       <java.version>1.8</java.version>
   </properties>

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

</project>

给我错误的类是HelloWorldConfiguration.java类

The class that is giving me the error is the HelloWorldConfiguration.java class

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HelloWorldConfiguration {

    public static void main(String[] args) {
        SpringApplication.run(HelloWorldConfiguration.class, args);
    }

}

任何帮助都将不胜感激。谢谢。

Any help would be greatly appreciated. Thank you.

推荐答案

你的Maven缓存在第二台机器上损坏了。无法打开JAR,这就是您获得此异常的原因。

Your Maven cache is corrupted on the second machine. The JAR can't be opened, that's why you get this exception.

您可以通过在该项目的第二台机器上运行此命令来解决此问题:

You can fix that by running this command on the second machine for that project:

mvn dependency:purge-local-repository

如果这不起作用,请尝试删除该计算机上的本地仓库(〜/ .m2 / repository / org / springframework )并运行 mvn package 再次。

If that doesn't work, try remove your local repo on that machine (~/.m2/repository/org/springframework) and run mvn package again.

这篇关于无法解析org.springframework.context.ConfigurableApplicationContext类型。它是从所需的.class文件间接引用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆