标签:java spring spring-boot maven pom-xml
我正在按照spring.io的教程使用spring boot构建一个spring应用程序.
我可以让程序在一台计算机上完美运行.
当我尝试不同的计算机时,我收到以下错误
The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files
我尝试删除和添加我的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);
}
}
任何帮助将不胜感激.谢谢.
解决方法:
您的Maven缓存在第二台计算机上已损坏.无法打开JAR,这就是您获得此异常的原因.
您可以通过在该项目的第二台计算机上运行此命令来解决此问题:
mvn dependency:purge-local-repository
如果这不起作用,请尝试删除该计算机上的本地存储库(〜/ .m2 / repository / org / springframework)并再次运行mvn软件包.
标签:java,spring,spring-boot,maven,pom-xml 来源: https://codeday.me/bug/20191005/1857519.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。