2015-08-25 81 views
0

我有一個ivy.xml文件(無ivysettings.xml文件)具有以下依賴性:如何防止常春藤下載同一依賴項的多個版本?

<dependency org="org.freemarker" name="freemarker" rev="2.3.23"/> 

然而,當我解決我的常春藤依賴我結束了freemarker-2.3.8.jarfreemarker-2.3.23.jar。這在Apache Tomcat中造成了一個問題,因爲2.3.8.jar優先於2.3.23.jar,而Configuration.VERSION_2_3_23這個在運行時顯示爲不可用(儘管它可用於編譯時)。下面是完整的的ivy.xml的情況下,它可以幫助:

<ivy-module version="2.0"> 
    <info organisation="com.example" module="ExampleProject"/> 
    <configurations defaultconfmapping="default"> 
     <conf name="default"/> 
     <conf name="java8" extends="default" description="Java 8 dependencies"/> 
     <conf name="eclipse" description="Special dependencies in Eclipse"/> 
     <conf name="utest" extends="eclipse" description="Unit testing dependencies"/> 
    </configurations> 

    <dependencies> 
     <dependency org="com.amazonaws" name="aws-java-sdk-s3" rev="1.10.6"/> 
     <dependency org="org.slf4j" name="slf4j-simple" rev="1.7.10" /> 
     <dependency org="org.lesscss" name="lesscss" rev="1.7.0.1.1"/> 
     <dependency org="com.github.mfornos" name="humanize-slim" rev="1.2.1"/> 
     <dependency org="com.google.code.gson" name="gson" rev="2.3.1"/> 
     <dependency org="com.lambdaworks" name="scrypt" rev="1.4.0"/> 
     <dependency org="commons-cli" name="commons-cli" rev="1.2"/> 
     <dependency org="commons-codec" name="commons-codec" rev="1.10"/> 
     <dependency org="commons-fileupload" name="commons-fileupload" rev="1.3.1"/> 
     <dependency org="joda-time" name="joda-time" rev="2.8.1"/> 
     <dependency org="mysql" name="mysql-connector-java" rev="5.1.36"/> 
     <dependency org="org.apache.ant" name="ant" rev="1.9.6"/> 
     <dependency org="org.apache.commons" name="commons-lang3" rev="3.4"/> 
     <dependency org="org.apache.httpcomponents" name="httpclient" rev="4.5"/> 
     <dependency org="org.freemarker" name="freemarker" rev="2.3.23"/> 
     <dependency org="org.hibernate" name="hibernate-c3p0" rev="4.3.10.Final"/> 
     <dependency org="org.hibernate" name="hibernate-core" rev="4.3.10.Final"/> 
     <dependency org="org.hibernate" name="hibernate-search" rev="4.5.1.Final"/> 
     <dependency org="org.hibernate" name="hibernate-tools" rev="4.3.1.CR1"/> 

     <dependency org="org.imgscalr" name="imgscalr-lib" rev="4.2"/> 
     <dependency org="org.jadira.usertype" name="usertype.core" rev="3.1.0.GA"/> 
     <dependency org="org.jsoup" name="jsoup" rev="1.8.3"/> 
     <dependency org="org.projectlombok" name="lombok" rev="1.16.6" /> 
     <dependency org="org.tuckey" name="urlrewritefilter" rev="4.0.4"/> 
    </dependencies> 
</ivy-module> 

回答

1

「的freemarker-2.3.8.jar」是"freemarker:freemarker" module的一部分,是

<dependency org="org.hibernate" name="hibernate-tools" rev="4.3.1.CR1"/> 

傳遞依賴我會建議以下修補程序,告訴常春藤排除不需要的模塊:

<ivy-module version="2.0"> 
    .. 
    ..  
    <dependencies> 
     .. 
     .. 

     <exclude org="freemarker" module="freemarker"/> 
    </dependencies> 
</ivy-module> 

爲了幫助診斷這個問題,我使用的回購rt任務來分析每個ivy配置的內容。

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant"> 

    <target name="resolve"> 
    <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision](-[classifier]).[ext]"/> 
    <ivy:report todir="reports" graph="false"/> 
    </target> 

</project> 
+0

我把你的答案和實施是'<依賴組織= 「org.hibernate作爲」 NAME = 「休眠工具」 REV = 「4.3.1.CR1」> <排除有機= 「freemarker的」 模塊=「freemarker」/>'它工作! –

相關問題