当我尝试添加Spring Cloud依赖项时,我的项目出现以下错误,由于某些版本冲突而无法解决。请帮助我确定问题并解决。
您好,有一个Spring Boot项目:
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.8</version>
</dependency>
</dependencies>
由于位置异常,加载默认的TestExecutionListener类名称时出现以下错误,并且[org / springframework / boot / autoconfigure / web / ServerPropertiesAutoConfiguration.class]无法打开,因为它不存在 例外。
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time
elapsed: 2.692 s <<< FAILURE! - in
com.package.packageApplicationTests
[ERROR] contextLoads(com.package.packageApplicationTests) Time
elapsed: 0.002 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by:
org.springframework.beans.factory.BeanDefinitionStoreException:
Failed to process import candidates for configuration class
[com.package.packageApplication]; nested exception is
java.io.FileNotFoundException: class path resource
org/springframework/boot/autoconfigure
/web/ServerPropertiesAutoConfiguration.class cannot be opened
because it does not exist
Caused by: java.io.FileNotFoundException: class path resource
org/springframework/boot/autoconfigure/web/
ServerPropertiesAutoConfiguration.class cannot be opened because it
does not exist
答案 0 :(得分:0)
您是否尝试过在springboot head版本之后删除version标签?看起来您的某些依赖项在版本之间添加了一些不兼容的依赖项。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>