我在POM中使用Apache版本3.8。但由于某些内部依赖,它仍在下载poi-3.2和poi-3.8 (可能是)。对于我来说,奇怪的行为是我使用poi-3.2的项目,即使我在POM中提到了3.8版本。我在谷歌上搜索了很多相同的东西,但发现自己运气不佳。这是我的POM条目:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>
<type>jar</type>
</dependency>我已经通过代码检查了我在类路径中使用的poi jar:
ClassLoader classloader =
org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
URL res = classloader.getResource(
"org/apache/poi/poifs/filesystem/POIFSFileSystem.class");
String path = res.getPath();
System.out.println("Core POI came from " + path);这些指纹:
Core POI came from file:/D:/Software/Softwares/apache-tomcat-6.0.33/webapps/scd-web/WEB-INF/lib/poi-3.2.jar!/org/apache/poi/poifs/filesystem/POIFSFileSystem.class在同一个文件夹中有一个poi-3.8.jar,但类路径的值为3.2。
,我的问题是:我应该做些什么,以便我的项目使用poi-3.8.jar而不是poi-3.2.jar。
非常感谢!!
编辑:输出的mvn dependency:tree
[INFO] Building SCD-common [INFO] task-segment: [dependency:tree]
[INFO]
------------------------------------------------------------------------
[WARNING] While downloading xmlbeans:xmlbeans:2.3.0 This artifact has been relocated to org.apache.xmlbeans:xmlbeans:2.3.0.
[INFO] [dependency:tree] [INFO] com.idc:scd-common:jar:4.2.0.5
[INFO] +- org.springframework:spring-webmvc:jar:2.5.6:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | +- org.springframework:spring-beans:jar:2.5.6:compile
[INFO] | +- org.springframework:spring-context-support:jar:2.5.6:compile
[INFO] | \- org.springframework:spring-web:jar:2.5.6:compile
[INFO] +- com.idc.worldwide.keystones:service-single-signon-dynamo-api:jar:1.0:compile
[INFO] +- com.idc.worldwide.keystones:service-single-signon-dynamo-database-impl:jar:1.0.3:compile
[INFO] | +- org.apache:commons-dbcp:jar:1.2.2:compile
[INFO] | +- org.apache:commons-pool:jar:1.4:compile
[INFO] | \- com.idc.worldwide.webchannel:sage-core:jar:3.2.0.001:compile
[INFO] | +- com.idc.webchannel.legacy.sage-dependencies:aspose-slides:jar:1. 0:compile
[INFO] | +- com.servlets:cos:jar:09May2002:compile
[INFO] | +- com.sun:jai_codec:jar:1.1.3:compile
[INFO] | +- com.sun:jai_core:jar:1.1.3:compile
[INFO] | +- com.verity:k2:jar:5.00.3177.0:compile
[INFO] | +- org.apache:poi:jar:3.2:compile
[INFO] | +- org.apache:poi_contrib:jar:3.2:compile
[INFO] | +- org.apache:poi_scratchpad:jar:3.2:compile
[INFO] | \- org.springframework:spring:jar:2.5.6:compile
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile发布于 2012-12-31 12:36:20
看起来像
org.apache:poi:jar:3.2的编译依赖项
com.idc.worldwide.keystones:service-single-signon-dynamo-database-impl(虽然我认为你可能剪了些东西)
和
org.apache.poi:poi:jar:3.8不是依赖项(它不在依赖树中)。
确保您的<dependency>条目在<dependencies>标记中。
发布于 2012-12-31 11:46:18
有各种mvn命令来帮助解决这个问题:
mvn dependency:analyze-dep-mgt
将打印有关依赖性解析的详细信息。
mvn dependency:tree
将打印依赖树(对于查看依赖项的依赖关系非常有用)
mvn help:effective-pom
将打印由您的pom层次结构合并产生的pom。
如果在maven中找不到对poi-3.2的任何引用,则可以查看IDE中的类路径。你有没有添加过的jar?
用这些命令的结果编辑您的问题对我们帮助您很有帮助。
发布于 2012-12-31 11:44:39
跑
mvn dependency:tree 检查哪个库具有传递到poi 3.2的依赖关系。然后,您可以将其排除在pom中。
<dependency>
<groupId>sample.group</groupId>
<artifactId>sample-artifactB</artifactId>
<version>1</version>
<exclusions>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
</exclusions>
</dependency>https://stackoverflow.com/questions/14101015
复制相似问题