Java 9 模块测试错误

4

我用Maven编写了Java 9 模块化应用程序,现在我想添加测试用例。

当我尝试在整个项目上运行mvn clean install命令时,出现了以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:testCompile (default-testCompile) on project EmployeeModule: Fatal error compiling: invalid flag: -Xmodule:EmployeeModule -> [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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :EmployeeModule

奇怪的是,我可以在Intellij中运行这个项目而没有警告或错误,我也可以在此模块中运行测试而没有错误。

我正在使用来自Oracle网站的Java 9和Maven 3.5.0。 抱歉,我无法用java9标记它。

1个回答

7

您应该使用maven-compiler-plugin 3.7.0版本,因为3.6.x版本是基于旧的模块类定义的,所以在使用Java 9时已经变得无用。


太简单了:D谢谢! - amkz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接