问题描述
在Maven中遇到编译错误:
Getting a compilation error in Maven:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/prototypes/demo-sse-spring-boot-master/src/test/java/com/cedric/demo/sse/SseDemoApplicationTests.java:[6,37] package org.springframework.boot.test does not exist
[ERROR] /C:/TITAN/demo-sse-spring-boot-master/src/test/java/com/cedric/demo/sse/SseDemoApplicationTests.java:[10,2] cannot find symbol
symbol: class SpringApplicationConfiguration
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Maven回购中似乎有jar:
Maven repo seems to have the jar present:
但是,该jar中没有任何已编译的类.仅META-INF目录:
howerever that jar doesn't have any compiled classes inside it. only META-INF dir:
这是设计使然吗?在哪里可以找到包含 SpringApplicationConfiguration 类的jar,以使Maven开心?
Is that by design? Where do I get the jar containing SpringApplicationConfiguration class to make Maven happy?
这是我pom.xml的相关部分:
Here's the relevant parts of my pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>jquery</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
像所有其他Spring Boot入门者一样,
推荐答案
spring-boot-starter-test
实际上只是一个pom,它可传递地引入许多其他依赖项.它只有一个jar,可以使一些不喜欢仅含pom的依赖关系的构建系统满意.
spring-boot-starter-test
, like all the other Spring Boot starters, is really just a pom that pulls in a number of other dependencies transitively. It only has a jar to keep some build systems that don't like pom-only dependencies happy.
似乎您已将应用程序从Spring Boot 1.4升级到Spring Boot 1.5. Spring Boot 1.5删除了1.4中不推荐使用的许多类,包括org.springframework.boot.test.SpringApplicationConfiguration
.
It looks like you have upgraded an application from Spring Boot 1.4 to Spring Boot 1.5. Spring Boot 1.5 removes a number of classes that were deprecated in 1.4, including org.springframework.boot.test.SpringApplicationConfiguration
.
我建议回到Spring Boot 1.4.4.RELEASE并修复所有弃用警告.然后,您应该可以轻松升级到Spring Boot 1.5.1.RELEASE.
I would recommend dropping back to Spring Boot 1.4.4.RELEASE and fixing all of the deprecation warnings. You should then be able to upgrade to Spring Boot 1.5.1.RELEASE without difficulty.
这篇关于找不到SpringApplicationConfiguration:错误的spring-boot-starter-test内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!