Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9

末鹿安然 提交于 2019-12-04 04:59:30

In short, add a missing/misplaced class named module-info.java to include your project's module declaration at your project's source root. (e.g src/main/java)

Additionally, note to upgrade to the version 3.7.0 of the maven-compiler-plugin in case you have a comment included in your module-info class. [The logs seems pretty relevant to this.]


Or the other way, if you wish to compile your project with a previous version of Java then use the release flag as:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
    <configuration>
        <release>8</release>
        <verbose>true</verbose>
    </configuration>
</plugin>

Concepts

With Java9 marking the completion of the project Jigsaw therein introducing the Java Platform Module System (JPMS), projects build on Java version 9 and above would be modularised. This would include a primary compiled class called module-info.class which is that module's declaration.

The initial draft and eventually The State of the Module System describes best over the concepts followed and practiced.


An additional trick regard making Eclipse Oxygen current version compatible with Java 9

AFAIK the latest Oxygen builds (Oxygen.2 at this point in time) from Eclipse are meant to be Java9 compatible without any additional plugin support anymore.


Additional Useful Resources:

in the second edit, you have to add jdk to your build path. Go to windows->Preferences->Java->installed jre's and add the jdk, and check it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!