springboot打包出现异常
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.244 s <<< FAILURE! - in cn.itcast.sb_20200802.Sb20200802ApplicationTests
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
解决措施
在插件配置里添加如下代码
没添加之前
添加之后
<!-- 之前的-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 新增的-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
添加之后成功了
直接在jar目录下输入cmd 再cmd中运行
运行成功