【发布时间】:2017-02-26 10:18:39
【问题描述】:
我正在按照spring.io 的教程使用 Spring Boot 构建一个 Spring 应用程序。
我可以让程序在一台计算机上完美运行。 当我在另一台计算机上尝试时,出现以下错误
org.springframework.context.ConfigurableApplicationContext 类型无法解析。它是从所需的 .class 文件中间接引用的
我尝试删除和添加我的 JRE 系统库 (JDK 1.8),以及使用 maven 清理和更新项目,甚至删除并重新导入整个项目。所有这些方法都没有成功。
我的 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 类
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);
}
}
任何帮助将不胜感激。谢谢。
【问题讨论】:
-
在它不工作的第二台机器上,在你的本地 m2 repo 中验证 maven 依赖项是否正常,这意味着 jars 存在并且没有损坏
-
jars 存在,但我如何验证它们是否已损坏,如果是,我该如何修复它们?
-
用 7zip 或类似的软件打开它们并检查类是否存在
-
试试这个link。
-
@RITZXAVI 我已经尝试了该链接,但它没有解决问题。 @Nadir 再次检查我不确定罐子是否存在。在 .m2 我有
...\.m2\repository\org\springframework\spring-context而不是...\.m2\repository\org\springframework\context
标签: java spring maven spring-boot pom.xml