Spring Boot无法运行maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter [英] Spring Boot fails to run maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter

查看:311
本文介绍了Spring Boot无法运行maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 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:

错误:找不到或加载主类 org.apache.maven.surefire.booter.ForkedBooter

Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter

原因: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆