我遇到了问题,当我运行
mvn test
时。以下是输出的一部分:Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] Unable to create test class 'com.models.ExampleTest'
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] Unable to create test class 'com.ExampleTest'
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:657)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1161)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1002)
这是我的pom.xml的一部分:
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
我添加了<useSystemClassLoader>false</useSystemClassLoader>
,因为当我执行mvn test命令时出现了Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter
的问题。所以我认为我的ClassLoader有些问题。我使用的是Ubuntu 18.04、openjdk-11和maven 3.6.0。但我也尝试过在oracle-jdk-11和openjdk-8上运行这个命令。此外,这个问题并不取决于项目。我创建了一个空项目,并添加了一个简单的类和简单的测试 - 结果是相同的。