我如何诊断和修复类路径问题? [英] How do i diagnose and fix classpath problems?

查看:115
本文介绍了我如何诊断和修复类路径问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个tycho项目,其中包括xtend源.我的依赖项之一来自JUnit的较旧版本,该版本未包含我需要的所有功能.我还依赖于JUnit 4.11. Tycho构建很好,但是xtend编译器(xtend-maven-plugin)似乎看到的是旧的JUnit版本而不是新的JUnit版本.我该如何解决?

I have a tycho project that includes xtend sources. One of my dependencies comes with an older version of JUnit that does not include all features that i need. I also have a dependency on JUnit 4.11. Tycho build is fine, but the xtend compiler (xtend-maven-plugin) seems to see the old JUnit version instead of the new one. How can i fix this?

要澄清一下,这就是我的依赖项的样子:

To clarify, this is how my dependencies look like:

Project A
|--Project B
|  |-- JUnit 4.8.2
|--JUnit 4.11

在tyg的OSGi世界中,这没问题.但是,xtend编译器使用JUnit 4.8.2类解析项目A中的类.我知道这是因为有问题的类是注释@Parameters,它在4.11中获得了属性名称".而这正是使xtend maven插件无法正确编译的有问题的部分. Eclipse xtend工具似乎没有问题.

In the OSGi world of tycho, this is no problem. However, the xtend compiler resolves classes in Project A with JUnit 4.8.2 classes. I know this because the offending class is the annotation @Parameters, which gained the attribute "name" in 4.11. And this is exactly the offending part which keeps the xtend maven plugin from properly compiling. The Eclipse xtend tools seem to have no problems.

推荐答案

这里可能存在几个问题:

There can be several problems here:

  1. 当您开始测试时,Eclipse会将JUnit放在您的类路径中.它需要JUnit运行程序能够与正在运行的测试过程进行对话.这很少会引起问题,但是您应该意识到这一点.

  1. Eclipse will put JUnit on your classpath when you start the tests. It needs that for it's JUnit runner to be able to talk to the running test process. This rarely causes problems but you should be aware of it.

如果您不想传递依赖,请在POM中的<dependency>内添加一个<exclude>元素.当然,这仅适用于POM优先构建,这在Eclipse世界中似乎很少见.

It you don't want a transitive dependency, add an <exclude> element inside of <dependency> in your POM. This of course only works for POM-first builds which seem rare in the Eclipse world.

如果使用Manifest-First构建,那么您正在处理OSGi. OSGi不允许您排除依赖关系,但它也隔离了不同的部分,因此Xtend编译器可以毫无问题地使用它的JUnit旧版本,因为您的其他插件看不到它.

If you use Manifest-First builds, then you're dealing with OSGi. OSGi doesn't allow you exclude dependencies but it also isolates the different parts, so the Xtend compiler can use it's ancient version of JUnit without problems since your other plugins won't see that.

因此,下一步是找出该依赖关系的来源,并适当地排除它.

So the next step is to figure out where that dependency is coming from and excluding it properly.

为了更好地帮助您,我需要更多地了解为什么您认为"xtend编译器似乎看到了旧的JUnit版本".

To help you better, I need to know more about why you think that "the xtend compiler seems to see the old JUnit version".

这篇关于我如何诊断和修复类路径问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆