Maven 未找到SpringApplicationConfiguration:错误的spring启动程序测试内容?
在Maven中获取编译错误:Maven 未找到SpringApplicationConfiguration:错误的spring启动程序测试内容?,maven,testing,spring-boot,spring-boot-test,Maven,Testing,Spring Boot,Spring Boot Test,在Maven中获取编译错误: [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /C:/prototypes/demo-sse-spring-boot-master/src/test/java/com
[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 repo似乎有一个jar:
然而,jar中没有任何编译过的类。仅META-INF目录:
这是故意的吗?我在哪里可以得到包含SpringApplicationConfiguration类的jar来让Maven开心呢
以下是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>
org.springframework.boot
spring启动程序父级
1.5.1.1发布
UTF-8
1.8
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
弹簧靴开发工具
org.webjars.bower
jquery
2.1.3
org.webjars
独自创立
3.3.1
org.projectlombok
龙目
1.16.4
org.springframework.boot
springbootmaven插件
与所有其他spring boot starter测试一样,spring boot starter测试实际上只是一个pom,可传递地引入许多其他依赖项。它只有一个jar来保持一些不喜欢pom依赖的构建系统
看起来您已经将应用程序从Spring Boot 1.4升级到Spring Boot 1.5。SpringBoot1.5删除了许多在1.4中被弃用的类,包括org.springframework.Boot.test.SpringApplicationConfiguration
我建议回到Spring Boot 1.4.4.RELEASE并修复所有的弃用警告。然后,您应该能够毫无困难地升级到Spring Boot 1.5.1.RELEASE。Spring Boot starter测试与所有其他Spring Boot starter测试一样,实际上只是一个pom,它可以过渡地引入许多其他依赖项。它只有一个jar来保持一些不喜欢pom依赖的构建系统
看起来您已经将应用程序从Spring Boot 1.4升级到Spring Boot 1.5。SpringBoot1.5删除了许多在1.4中被弃用的类,包括org.springframework.Boot.test.SpringApplicationConfiguration
我建议回到Spring Boot 1.4.4.RELEASE并修复所有的弃用警告。然后,您应该能够毫不费力地升级到Spring Boot 1.5.1.RELEASE。在您的版本中,@SpringApplicationConfiguration
注释不再存在。新注释包括:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = YourApplicationMainClass.class)
@WebAppConfiguration
在您的版本中,@SpringApplicationConfiguration
注释不再存在。新注释包括:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = YourApplicationMainClass.class)
@WebAppConfiguration
由于该错误是由于Spring Boot从1.4升级到1.5造成的,因此(从下面)需要注意的是,在1.4中引入的几个新类不推荐了一些现有类,导致最终在1.5中被删除。有关详情,请浏览:
引自网站(编辑):
此外,SpringBoot1.4(及以上版本)试图合理化和简化SpringBoot测试的各种运行方式。您应该迁移以下内容以使用新的@SpringBootTest注释:
从@SpringApplicationConfiguration(classes=MyConfig.class)
到@SpringBootTest(classes=MyConfig.class)
从@ContextConfiguration(classes=MyConfig.class,loader=SpringApplicationContextLoader.class)
到
@SpringBootTest(classes=MyConfig.class)
从@IntegrationTest
到
@SpringBootTest(webEnvironment=webEnvironment.NONE)
从带有WebAppConfiguration的集成测试到
@springbootest(webEnvironment=webEnvironment.DEFINED\u PORT)(或随机\u PORT)
从@WebIntegrationTest
到
@springbootest(webEnvironment=webEnvironment.DEFINED\u PORT)(或随机\u PORT)
提示:迁移测试时,您可能还需要替换任何
@RunWith(SpringJUnit4ClassRunner.class)
使用Spring4.3的声明
更可读的@RunWith(SpringRunner.class)
由于该错误是由于Spring Boot从1.4升级到1.5造成的,因此(从下面)需要注意的是,在1.4中引入的几个新类不推荐了一些现有类,导致最终在1.5中被删除。有关详情,请浏览:
引自网站(编辑):
此外,SpringBoot1.4(及以上版本)试图合理化和简化SpringBoot测试的各种运行方式。您应该迁移以下内容以使用新的@SpringBootTest注释:
从@SpringApplicationConfiguration(classes=MyConfig.class)
到@SpringBootTest(classes=MyConfig.class)
从@ContextConfiguration(classes=MyConfig.class,loader=SpringApplicationContextLoader.class)
到
@SpringBootTest(classes=MyConfig.class)
从@IntegrationTest
到
@SpringBootTest(webEnvironment=webEnvironment.NONE)
从带有WebAppConfiguration的集成测试到
@SpringBootTest(webEnvironment=webEnvironment.DEFINED\u PORT)(