相关疑难解决方法(0)

Maven surefire和JDK 11

我试图让Maven确定在JDK 11下运行,但我不断收到这些错误:

  1. 如果我设置reuseForks为true:
  Error occurred in starting fork, check output in log
  Process Exit Code: 1
  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:670)
  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
Run Code Online (Sandbox Code Playgroud)
  1. 如果我将其设置为false:
Execution default-test of goal org.apache.maven.plugins:maven-surefire-   plugin:3.0.0-M1:test
failed: java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.StartupReportConfiguration
Run Code Online (Sandbox Code Playgroud)

我发现这个和这个链接描述了同样的问题,但他们没有任何解决方案.

为了复制这个bug,我创建了这个git repo

java testing maven maven-surefire-plugin java-11

6
推荐指数
2
解决办法
3550
查看次数

maven Surefire 插件不使用 --enable-preview 模式

这是我的 pom.xml:

...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>13</source>
                <target>13</target>
                <release>13</release>
                <compilerArgs>
                    --enable-preview
                </compilerArgs>
            </configuration>
        </plugin>
...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>
                <reuseForks>false</reuseForks>
                <argLine>--enable-preview</argLine>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

问题是构建正常,但是当启动测试时我得到:

[错误] 无法在项目 foo-project 上执行目标 org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test):执行目标 org.apache.maven 的默认测试.plugins:maven-surefire-plugin:3.0.0-M4:测试失败:java.lang.UnsupportedClassVersionError:未为其/project/MyTest启用预览功能(类文件版本57.65535)。尝试使用 '--enable-preview' 运行 -> [帮助 1]

我必须在 pom.xml 中插入什么才能在启用预览模式的情况下执行测试?

谢谢。

java maven maven-surefire-plugin java-13

6
推荐指数
1
解决办法
1670
查看次数

标签 统计

java ×2

maven ×2

maven-surefire-plugin ×2

java-11 ×1

java-13 ×1

testing ×1