[英]Why and when is Eclipse putting Maven dependencies in the CLASSPATH and not in the MODULEPATH?
I have a Java 11 project which defines a module-info.java and is compliant with JPMS - except that it requires unnamed modules from other developers that did not yet care about JPMS.我有一个 Java 11 项目,它定义了一个 module-info.java 并且符合 JPMS - 除了它需要来自其他尚未关心 JPMS 的开发人员的未命名模块。
When I put the Maven dependencies in the module path, that is, in the .classpath
of Eclipse I have当我将 Maven 依赖项放在模块路径中时,即在 Eclipse 的.classpath
中我有
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
then everything works just fine.然后一切正常。 However, when I select Maven -> Update Project in Eclipse, then Eclipse will remove the line但是,当我 select Maven -> 更新 Eclipse 中的项目时,则 Z32F7227889194DEE83E 行将删除
<attribute name="module" value="true"/>
After that, the project shows an error in Eclipse (" The type xxx cannot be resolved. It is indirectly referenced from required.class file. ").之后,项目在Eclipse中显示错误(“无法解析类型xxx。它是从required.class文件中间接引用的。 ”)。
How can I tell Maven to keep the <attribute name="module" value="true"/>
upon "Maven -> Update Project...".我如何告诉 Maven 在“Maven -> 更新项目...”上保留<attribute name="module" value="true"/>
。
(Eclipse version is 2020-03) (Eclipse 版本为 2020-03)
I use this in my pom.xml
:我在我的pom.xml
中使用它:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>${java.version}</release>
<fork>true</fork>
<showWarnings>true</showWarnings>
<debug>true</debug>
<debuglevel>source,lines</debuglevel>
<verbose>true</verbose>
<modulePath>
<dependency>org.apache.logging.log4j:log4j-api</dependency>
<dependency>org.apache.logging.log4j.core:log4j-core</dependency>
... etc ...
</modulePath>
</configuration>
</plugin>
But, unfortunately, some modulePath > dependency
work fine, others do not.但是,不幸的是,一些modulePath > dependency
可以正常工作,而其他的则不行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.