gpt4 book ai didi

java - 如何防止 Ivy 下载同一依赖项的多个版本?

转载 作者:行者123 更新时间:2023-12-01 11:12:27 24 4
gpt4 key购买 nike

我有一个具有以下依赖项的 ivy.xml 文件(没有 ivysettings.xml 文件):

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

但是,当我解决 ivy 依赖项时,我最终得到 freemarker-2.3.8.jarfreemarker-2.3.23.jar。这会导致 Apache Tomcat 出现问题,因为 2.3.8.jar 优先于 2.3.23.jarstatic final int名为 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>

最佳答案

“freemarker-2.3.8.jar”是 "freemarker:freemarker" module 的一部分并且是

的传递依赖
<dependency org="org.hibernate" name="hibernate-tools" rev="4.3.1.CR1"/>

我建议进行以下修复,告诉ivy排除不需要的模块:

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

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

为了帮助诊断这个问题,我使用了报告任务来分析每个 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>

关于java - 如何防止 Ivy 下载同一依赖项的多个版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32196250/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com