如何在 Eclipse.classpath 中的所有其他依赖项之上自动设置 JRE_CONTAINER?
我想自动修改 Maven Eclipse 插件编写classpathentry
的顺序。有办法做到这一点吗?
我想这样做有两个原因。
第一个原因:在我的应用程序中,接口org.w3c.dom.Node
是由几个第三方库(用于XML处理)以及JDK( 1.6)。然而,与 JDK 相比,这些库提供的 org.w3c.dom.* 类的版本相当旧。例如,方法 Node.getTextContent()
在那里不存在。
在我的项目上运行 mvn eclipse:eclipse
会将这些库放置在 .classpath
中的 JDK 容器之前,在 Eclipse 中使用此方法将导致编译错误。因此,我们的想法是将这一行:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
放在 .classpath
文件的开头。
第二个原因(不太重要)是当我运行mvn eclipse:eclipse
时,它总是在之前设置我的
的,这让我有点困扰(是的,我知道在 TDD 中我们首先开发测试,但仍然......)src/test/*
包>src/java/*
技术信息:Java 1.6、Maven 2.2.1、Eclipse 插件 2.8
编辑:这里有一个问题可能与我的类似,但它对我没有帮助,因为它只处理第三方依赖项的顺序......
I want to modify automatically the order on which classpathentry
are written by the Maven Eclipse plugin. Is there a way to do that?
I want to do that for two reasons.
First reason: in my application, the interface org.w3c.dom.Node
is provided by several third-party libraries (for XML processing), as well as the JDK (1.6). However, the version of org.w3c.dom.*
classes provided by these libraries are quite old compared to the JDK. For example, the method Node.getTextContent()
does not exist there.
Running mvn eclipse:eclipse
on my project will place these library before the JDK container in the .classpath
, using this method in Eclipse will result in a compilation error. So the idea is to put this line:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
at the beginning of the .classpath
file.
The second reason (less important) is when I run mvn eclipse:eclipse
, it always set my src/test/*
packages before src/java/*
ones, which bothers me a little (yes, I know that in TDD we develop tests first, but still...)
Technical information: Java 1.6, Maven 2.2.1, Eclipse plugin 2.8
Edit: There is a question here that could look similar to mine, but it did not help me as it only deals with the order for third-party dependencies...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅这篇文章:Maven 类路径顺序问题。我可以确认 2.9 插件已经解决了这个问题(或者允许您 对配置进行模糊处理)。
See this post: Maven classpath order issues. I can confirm that the 2.9 plugin has fixed this issue (or allows you to futz with the config).