springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!

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] 

解决措施
在插件配置里添加如下代码

没添加之前
springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!_第1张图片
添加之后

springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!_第2张图片


		 <!-- 之前的-->
         <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>

添加之后成功了
springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!_第3张图片

////
直接在jar目录下输入cmd 再cmd中运行
springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!_第4张图片

运行成功
springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!_第5张图片

你可能感兴趣的:(springboot打包出现异常cn.itcast.sb_20200802.Sb20200802ApplicationTests Time elapsed: 0.243 s <<< ERROR!)