运行 Spring Boot 2.0.2.RELEASE 应用程序的 maven (3.5.2) 构建(由具有 Web 依赖项的 Web 初始化程序生成)执行 maven-surefire-plugin 失败,只是说:
错误:无法找到或加载主类 org.apache.maven.surefire.booter.ForkedBooter
引起:java.lang。 ClassNotFoundException :org.apache.maven.surefire.booter。 ForkedBooter
为什么会这样?它是引导中的问题+肯定集成=错误吗?
作为参考,似乎相关的依赖项是:
<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>
原文由 jediz 发布,翻译遵循 CC BY-SA 4.0 许可协议
该问题的解决方法是覆盖 Spring Boot 的
maven-surefire-plugin
定义并将useSystemClassLoader
设置为false
。阅读 Surefire 文档 了解更多详情