英文:
Maven is making unwanted changes to the Eclipse .classpath
问题
我最近在我的pom.xml中添加了一些新项目。由于某种原因,在添加了这些新项目之后,当我运行Maven项目更新时,它会修改Eclipse的.classpath文件。
以下是被添加到pom.xml中的项目:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j-version}</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
在Maven进行项目更新后的.classpath文件中,它添加了:including="**/*.java"
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
...
</classpath>
因此,当我运行Java程序时,无法找到任何资源,因为它们不是.java文件。我不确定为什么这些被添加到Maven的新项目会突然修改Eclipse的.classpath文件。我尝试手动删除including="**/*.java",但是一旦Maven再次进行项目更新,它会将其添加回去。
有人知道为什么会出现这种情况吗?我感谢帮助,谢谢。
英文:
I recently added some new items to my pom.xml. For some reason, after adding these new items, and I run a Maven project update, it modifies the Eclipses .classpath.
Here are the pom.xml items that were added:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j-version}</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
In the .classpath after Maven does a project update, it adds: including="**/*.java"
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
...
</classpath>
Because of this, when I run the java, none of my resources are being found because they're not .java. I'm not sure why those new items that were added to Maven, are making it suddenly modify the Eclipse .classpath. I tried manually removing the including="**/*.java", but once Maven does another project update, it puts it back.
Does anyone have an idea why this is occurring? I appreciate the help, thanks.
答案1
得分: 1
如果您在Eclipse中使用Maven,那么m2e插件会控制.classpath
文件。
您需要通过POM管理您的资源,而不是通过.classpath
。
英文:
If you use Maven in Eclipse, then the m2e plugin controls the .classpath
file.
You need to manage your resources through the POM, not through .classpath
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论