问题描述
运行 Spring Boot 2.0.2的Maven(3.5.2)版本(由具有Web依赖项的Web初始化程序生成)无法执行 maven-surefire-plugin 只是说:
Running maven (3.5.2) build of a Spring Boot 2.0.2.RELEASE applicaton (generated by web initialiser with web dependencies) fails executing the maven-surefire-plugin saying just:
原因:java.lang. ClassNotFoundException :org.apache.maven.surefire.booter. ForkedBooter
Caused by: java.lang.ClassNotFoundException: org.apache.maven.surefire.booter.ForkedBooter
为什么会这样?引导+ surefire集成=错误有问题吗?
Why is this happening? Is it a problem in boot + surefire integration = a bug?
作为参考,似乎相关的依赖项是:
For reference, the dependencies that seem relevant are:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>
...
<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-starter-web</artifactId>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
推荐答案
此问题的解决方法是重写Spring Boot的maven-surefire-plugin
定义并将useSystemClassLoader
设置为false
.阅读 Surefire文档以了解更多详情
Workaround for the issue was to override Spring Boot's maven-surefire-plugin
definition and set useSystemClassLoader
to false
. Read Surefire docs for more details
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
这篇关于Spring Boot无法运行maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!