Maven:我如何协调这种依赖性冲突?

时间:2011-11-29 22:05:04

标签: maven dependencies xerces http-unit

我有这个Maven依赖...

    <dependency>
        <groupId>javanettasks</groupId>
        <artifactId>httpunit</artifactId>
        <version>1.7</version>
        <scope>test</scope>
    </dependency>

对于我正在运行的一些测试,我需要这个。该库依赖于xercesImpl v 2.4。问题是,当我们通过Bamboo集成服务器运行它时,我们得到一个ClassCastException,因为我们的服务器使用更高版本的xerces。有谁知道如何调和这个?换句话说,有没有办法让我的xercesImpl在测试阶段在类加载器中占优势?

29-Nov-2011 12:55:12    Running com.myco.clearing.product.client.xmltohtml.XmlToHtmlServiceTest
29-Nov-2011 12:55:16    Loading inherited module 'com.myco.clearing.product.ProductPlusJUnit'
29-Nov-2011 12:55:16       [ERROR] Unexpected error while processing XML
29-Nov-2011 12:55:16    java.lang.ClassCastException: org.apache.xerces.parsers.XML11Configuration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
29-Nov-2011 12:55:16            at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
29-Nov-2011 12:55:16            at org.apache.xerces.parsers.SAXParser.<init>(Unknown Source)
29-Nov-2011 12:55:16            at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.<init>(Unknown Source)
29-Nov-2011 12:55:16            at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
29-Nov-2011 12:55:16            at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
29-Nov-2011 12:55:16            at com.google.gwt.dev.util.xml.ReflectiveParser.createNewSaxParser(ReflectiveParser.java:65)
29-Nov-2011 12:55:16            at com.google.gwt.dev.util.xml.ReflectiveParser.access$000(ReflectiveParser.java:46)
29-Nov-2011 12:55:16            at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.parse(ReflectiveParser.java:343)
29-Nov-2011 12:55:16            at com.google.gwt.dev.util.xml.ReflectiveParser$Impl.access$200(ReflectiveParser.java:68)
29-Nov-2011 12:55:16            at com.google.gwt.dev.util.xml.ReflectiveParser.parse(ReflectiveParser.java:418)
29-Nov-2011 12:55:16            at com.google.gwt.dev.cfg.ModuleDefLoader.nestedLoad(ModuleDefLoader.java:296)
29-Nov-2011 12:55:16            at com.google.gwt.dev.cfg.ModuleDefLoader$2.load(ModuleDefLoader.java:217)
29-Nov-2011 12:55:16            at com.google.gwt.dev.cfg.ModuleDefLoader.doLoadModule(ModuleDefLoader.java:324)
29-Nov-2011 12:55:16            at com.google.gwt.dev.cfg.ModuleDefLoader.createSyntheticModule(ModuleDefLoader.java:107)
29-Nov-2011 12:55:16            at com.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl2(CompileStrategy.java:165)
29-Nov-2011 12:55:16            at com.google.gwt.junit.CompileStrategy.maybeCompileModuleImpl(CompileStrategy.java:112)
29-Nov-2011 12:55:16            at com.google.gwt.junit.SimpleCompileStrategy.maybeCompileModule(SimpleCompileStrategy.java:36)
29-Nov-2011 12:55:16            at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1340)
29-Nov-2011 12:55:16            at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
29-Nov-2011 12:55:16            at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
29-Nov-2011 12:55:16            at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
29-Nov-2011 12:55:16            at junit.framework.TestCase.runBare(TestCase.java:134)
29-Nov-2011 12:55:16            at junit.framework.TestResult$1.protect(TestResult.java:110)
29-Nov-2011 12:55:17            at junit.framework.TestResult.runProtected(TestResult.java:128)
29-Nov-2011 12:55:17            at junit.framework.TestResult.run(TestResult.java:113)
29-Nov-2011 12:55:17            at junit.framework.TestCase.run(TestCase.java:124)
29-Nov-2011 12:55:17            at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
29-Nov-2011 12:55:17            at junit.framework.TestSuite.runTest(TestSuite.java:232)
29-Nov-2011 12:55:17            at junit.framework.TestSuite.run(TestSuite.java:227)
29-Nov-2011 12:55:17            at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
29-Nov-2011 12:55:17            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
29-Nov-2011 12:55:17            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
29-Nov-2011 12:55:17            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
29-Nov-2011 12:55:17            at java.lang.reflect.Method.invoke(Method.java:597)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
29-Nov-2011 12:55:17            at $Proxy0.invoke(Unknown Source)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
29-Nov-2011 12:55:17            at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)

谢谢, - 戴夫

1 个答案:

答案 0 :(得分:0)

您可以在客户端和服务器项目中将version Xerces定义为dependency。这将优先于httpunit对Xerces的传递依赖性。

但是,如果httpunit与您声明的Xerces版本不兼容,那么您就遇到了麻烦。