如何让 Eclipse 始终首选其他库包含的库的最新版本?
我的项目使用junit-4.8.2.jar和mockito-all-1.8.5.jar;两者都包括 Hamcrest 1.1。在我添加 hamcrest-all-1.2.jar 之前,它工作得很好;现在我收到各种 NoSuchMethodError,因为显然我的代码编译为 Hamcrest 1.2,但正在使用 Hamcrest 1.1 运行。
看起来有多种方法可以解决这个问题(例如使用 junit-dep-4.8.2 代替等),但是有没有办法告诉 Eclipse 更喜欢 Hamcrest 1.2。在运行时和编译时?
My project uses junit-4.8.2.jar and mockito-all-1.8.5.jar; both includes Hamcrest 1.1. This is working just fine until I added hamcrest-all-1.2.jar; now I get various NoSuchMethodError, because apparently my code compiles to Hamcrest 1.2, but is being run with Hamcrest 1.1.
It looks like there are various ways to solve this problem (e.g. use junit-dep-4.8.2 instead, etc), but is there a way to tell Eclipse to prefer Hamcrest 1.2. at run-time as well as compile-time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
评论中已经提到了,但我认为这也是一个有效的答案:使用 Maven 来处理依赖关系管理。如果您不想使用 Maven(因为您已经使用 Ant 或类似的东西),请使用 Ivy、Gradle、Buildr 或任何其他具有依赖管理功能的构建工具。
It was already mentioned in the comments, but i think it's also a valid answer: Use Maven to handle the dependency management. If you don't want to use Maven (because you already use Ant or anything like that), use Ivy, Gradle, Buildr or any other build tool with dependency management.