我已经用 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 标记它。
最佳答案
你应该使用 maven-compiler-plugin 3.7.0 3.6.x 基于模块类的旧定义,因此在使用 Java 9 时它们变得毫无用处。
关于Java 9 模块测试错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46474639/