![](/img/trans.png)
[英]In Eclipse, what is the difference between modulepath and classpath?
[英]Why and when is Eclipse putting Maven dependencies in the CLASSPATH and not in the MODULEPATH?
我有一个 Java 11 项目,它定义了一个 module-info.java 并且符合 JPMS - 除了它需要来自其他尚未关心 JPMS 的开发人员的未命名模块。
当我将 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>
然后一切正常。 但是,当我 select Maven -> 更新 Eclipse 中的项目时,则 Z32F7227889194DEE83E 行将删除
<attribute name="module" value="true"/>
之后,项目在Eclipse中显示错误(“无法解析类型xxx。它是从required.class文件中间接引用的。 ”)。
我如何告诉 Maven 在“Maven -> 更新项目...”上保留<attribute name="module" value="true"/>
。
(Eclipse 版本为 2020-03)
我在我的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>
但是,不幸的是,一些modulePath > dependency
可以正常工作,而其他的则不行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.