当我尝试使用 Maven 运行自动化测试用例时,出现以下错误。我运行了 project>run as> maven install
Failed to execute goal net.serenity-bdd.maven.plugins:serenity-maven-plugin:1.9.16:aggregate (serenity-reports) on project flightmode: Execution serenity-reports of goal net.serenity-bdd.maven.plugins:serenity-maven-plugin:1.9.16:aggregate failed: An API incompatibility was encountered while executing net.serenity-bdd.maven.plugins:serenity-maven-plugin:1.9.16:aggregate: java.lang.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>net.serenity-bdd.maven.plugins:serenity-maven-plugin:1.9.16
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/XXXXX/.m2/repository/net/serenity-bdd/maven/plugins/serenity-maven-plugin/1.9.16/serenity-maven-plugin-1.9.16.jar
[ERROR] urls[1] = file:/C:/XXXX/.m2/repository/net/serenity-bdd/serenity-core/1.9.16/serenity-core-1.9.16.jar
[ERROR] urls[2] = file:/C:/XXXX/.m2/repository/com/google/guava/guava/23.6-jre/guava-23.6-jre.jar
[ERROR] urls[3] = file:/C:/XXXXX/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
........
[ERROR] : Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @7a972f12
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
我也尝试使用 Java 21 运行,但仍然面临同样的问题, 还在 eclipse.ini 文件中添加了以下内容,仍然面临同样的问题
-Djava.security.manager=allow
--illegal-access=warn
--add-opens=java.base/java.lang=ALL-UNNAME
尝试使用
maven-surefire-plugin
插件
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</dependency>