簡體   English   中英

為什么以及何時 Eclipse 將 Maven 依賴項放在 CLASSPATH 中而不是 MODULEPATH 中?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM