SpringBoot项目打jar包报错的问题

问题是:最近在一次SpringBoot项目打包时发现,打jar包时报错,报错的信息如下:

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building wisdomeyeapi0114 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ wisdomeyeapi0114 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ wisdomeyeapi0114 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ wisdomeyeapi0114 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\xxx\xxx\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ wisdomeyeapi0114 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\xxx\xxx\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ wisdomeyeapi0114 ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.xxx.xxx.WisdomeyeapiApplicationTests
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.299 s <<< FAILURE! - in com.xxx.xxx.WisdomeyeapiApplicationTests
[ERROR] initializationError(com.xxx.xxx.WisdomeyeapiApplicationTests)  Time elapsed: 0.008 s  <<< ERROR!
java.lang.Exception: No runnable methods

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   WisdomeyeapiApplicationTests.initializationError ?  No runnable methods
[INFO] 
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.090 s
[INFO] Finished at: 2020-02-12T17:57:55+08:00
[INFO] Final Memory: 38M/292M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project wisdomeyeapi0114: There are test failures.
[ERROR] 

 看了错误信息后才知道最总要的是这句话,随后便查找原因。

 然后就去项目test包下的类中查看是这样的,报错原因就是没有可执行的方法

@RunWith(SpringRunner.class)
@SpringBootTest
public class XXXApplicationTests {




}

 解决办法:在test包下的类中添加一个测试方法,就可以了如下这样:  打包成功!

@RunWith(SpringRunner.class)
@SpringBootTest
public class XXXApplicationTests {
    @Test
    public void contextLoads() {
    }
}

至于为什么会这样,由于时间原因并不知道,希望有知道的大佬帮忙补充,感激不尽。

 

 

 

 

 

 

 

 

你可能感兴趣的:(SpringBoot)