WildFly 中的依赖项问题 - 在 pom 中.xml定义了运行时使用以外的其他版本



我在WildFly上运行的项目中的依赖项有问题。 在pom中.xml我对杰克逊库依赖有以下定义:

<dependencyManagement>
// ....
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.10.2</version>
</dependency>
// ...
</dependencyManagement>

但在运行时使用的是 2.1.4 版。我也在 IntelliJ 中看到它,它告诉我这个版本"因与 2.1.4 冲突而被省略">

版本2.1.4 包含在 WildFly 中,但我想使用版本 2.10.2。如何强制使用此版本库?

更新:

我的依赖树:

--- maven-dependency-plugin:2.8:tree (default-cli) @ myapp-ear ---
pl.net.me.myapp:myapp-ear:ear:1.0-SNAPSHOT
+- pl.net.me.myapp:myapp-ejb:ejb:1.0-SNAPSHOT:compile
|  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
|  |  - org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
|  +- org.apache.httpcomponents:httpclient:jar:4.5:compile
|  |  +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
|  |  - commons-logging:commons-logging:jar:1.2:compile
|  +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
|  +- commons-lang:commons-lang:jar:2.6:compile
|  +- commons-codec:commons-codec:jar:1.4:compile
|  +- org.jasig.cas.client:cas-client-core:jar:3.2.1:compile
|  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.2.Final:compile
|  +- org.drools:drools-core:jar:5.4.0.Final:compile
|  |  +- org.mvel:mvel2:jar:2.1.0.drools16:compile
|  |  - org.drools:knowledge-api:jar:5.4.0.Final:compile
|  +- net.sf.jasperreports:jasperreports:jar:6.0.3:compile
|  |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
|  |  +- commons-collections:commons-collections:jar:3.2.1:compile
|  |  +- commons-digester:commons-digester:jar:2.1:compile
|  |  +- com.itextpdf:itextpdf:jar:5.5.0:compile
|  |  +- com.itextpdf:itext-pdfa:jar:5.5.0:compile
|  |  +- jfree:jcommon:jar:1.0.15:compile
|  |  +- jfree:jfreechart:jar:1.0.12:compile
|  |  +- xml-apis:xml-apis:jar:1.3.02:compile
|  |  +- org.eclipse.jdt.core.compiler:ecj:jar:4.3.1:compile
|  |  +- org.codehaus.castor:castor-xml:jar:1.3.3:compile
|  |  |  +- org.codehaus.castor:castor-core:jar:1.3.3:compile
|  |  |  +- javax.inject:javax.inject:jar:1:compile
|  |  |  +- stax:stax:jar:1.2.0:compile
|  |  |  |  - stax:stax-api:jar:1.0.1:compile
|  |  |  +- javax.xml.stream:stax-api:jar:1.0-2:compile
|  |  |  - org.springframework:spring-context:jar:4.1.4.RELEASE:compile
|  |  |     +- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
|  |  |     |  - aopalliance:aopalliance:jar:1.0:compile
|  |  |     +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
|  |  |     +- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
|  |  |     - org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
|  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.1.4:compile
|  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.4:compile
|  |  +- org.apache.lucene:lucene-core:jar:4.5.1:compile
|  |  +- org.apache.lucene:lucene-analyzers-common:jar:4.5.1:compile
|  |  +- org.apache.lucene:lucene-queryparser:jar:4.5.1:compile
|  |  |  +- org.apache.lucene:lucene-queries:jar:4.5.1:compile
|  |  |  - org.apache.lucene:lucene-sandbox:jar:4.5.1:compile
|  |  |     - jakarta-regexp:jakarta-regexp:jar:1.4:compile
|  |  - org.olap4j:olap4j:jar:0.9.7.309-JS-3:compile
|  +- org.codehaus.groovy:groovy-all:jar:2.4.0:compile
|  +- org.apache.sanselan:sanselan:jar:0.97-incubator:compile
|  +- org.jbpm:jbpm-bpmn2:jar:5.4.0.Final:compile
|  |  +- org.jbpm:jbpm-flow-builder:jar:5.4.0.Final:compile
|  |  |  - org.jbpm:jbpm-flow:jar:5.4.0.Final:compile
|  |  - org.slf4j:slf4j-api:jar:1.6.4:compile
|  +- org.drools:drools-compiler:jar:5.4.0.Final:compile
|  |  +- org.antlr:antlr-runtime:jar:3.3:compile
|  |  +- org.antlr:antlr:jar:3.3:compile
|  |  - org.antlr:stringtemplate:jar:3.2.1:compile
|  +- org.drools:drools-clips:jar:5.4.0.Final:compile
|  +- org.drools:drools-decisiontables:jar:5.4.0.Final:compile
|  |  - net.sourceforge.jexcelapi:jxl:jar:2.6.10:compile
|  +- org.drools:drools-jsr94:jar:5.4.0.Final:compile
|  |  - jsr94:jsr94:jar:1.1:compile
|  +- org.drools:drools-persistence-jpa:jar:5.4.0.Final:compile
|  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
|  |  +- com.google.protobuf:protobuf-java:jar:2.4.1:compile
|  |  +- dom4j:dom4j:jar:1.6.1:compile
|  |  +- org.javassist:javassist:jar:3.14.0-GA:compile
|  |  - javax.transaction:jta:jar:1.1:compile
|  +- org.drools:drools-templates:jar:5.4.0.Final:compile
|  +- org.drools:drools-verifier:jar:5.4.0.Final:compile
|  |  +- com.google.guava:guava:jar:r06:compile
|  |  +- com.thoughtworks.xstream:xstream:jar:1.4.1:compile
|  |  |  +- xmlpull:xmlpull:jar:1.1.3.1:compile
|  |  |  - xpp3:xpp3_min:jar:1.1.4c:compile
|  |  - com.lowagie:itext:jar:2.1.2:compile
|  |     +- bouncycastle:bcmail-jdk14:jar:138:compile
|  |     - bouncycastle:bcprov-jdk14:jar:138:compile
|  +- org.drools:knowledge-internal-api:jar:5.4.0.Final:compile
|  +- commons-io:commons-io:jar:2.1:compile
|  +- pl.net.me.myapp:mka-commons-jar:jar:1.0-SNAPSHOT:compile
|  |  +- log4j:log4j:jar:1.2.17:compile
|  |  +- com.google.zxing:core:jar:3.1.0:compile
|  |  +- com.google.zxing:javase:jar:3.1.0:compile
|  |  - org.projectlombok:lombok:jar:1.18.10:compile
|  +- pl.net.me.myapp:myapp-cdm:jar:1.0-SNAPSHOT:compile
|  +- pl.net.me.myapp:myapp-database:jar:1.0-SNAPSHOT:compile
|  +- net.sf.jasperreports:jasperreports-fonts:jar:6.0.0:compile
|  +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.2:compile
|  - com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.2:import
+- pl.net.me.myapp:myapp-web:war:1.0-SNAPSHOT:compile
+- pl.net.me.myapp:iapp-web:war:1.0-SNAPSHOT:compile
+- pl.net.me.myapp:sop-web:war:1.0-SNAPSHOT:compile
- pl.net.me.myapp:my-maps:war:1.0-SNAPSHOT:compile

我找到了解决方案。在 WildFly 18.0.1 上一切正常,因为它包含杰克逊库的 2.9.10.1 版本。问题出在 WildFly 8.2.1 上,因为它包含版本 2.1.4。运行时使用的杰克逊库版本是WildFly提供的版本。

参考这个问题: 野蝇 9 - 如何排除杰克逊 我将文件 jboss-deployment-structure.xml 添加到我的 META-INF 目录中,并具有以下连续性:

<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.core.jackson-annotations" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>

不幸的是,它仅适用于 WildFly 18.0.1,WildFly 8.2.1 由于其他依赖问题而无法启动,因此在这种情况下最合理的解决方案是升级 WildFly 或从 pom 中删除 jackson-datatype-jsr310.xml

相关内容

  • 没有找到相关文章

最新更新