【发布时间】:2019-06-10 13:04:44
【问题描述】:
当我尝试将我的 Java EE 应用程序部署到 WildFly 15.0.1.Final 时,我一直看到此错误。
我看到 org.apache.directory.api::api-all depends on org.apache.servicemix.bundles::org.apache.servicemix.bundles.dom4j,以及后一个依赖 depends onorg.dom4j ::dom4j。另一方面,我的 WildFly 安装在 modules/system/layers/base/org/dom4j/main/ 中有 dom4j-2.1.1.jar
我在 pom.xml 中尝试了各种方法,例如使用 org.apache.servicemix.bundles::org.apache.servicemix.bundles.dom4j 和 org.dom4j::dom4j,排除它们并指定“避免”的范围。没有任何效果。
这是我的 pom.xml 中的 sn-p:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<finalWarName>ldapuserimport</finalWarName>
</properties>
<dependencies>
<!-- Java EE 7 dependency -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<version>1.0.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.3_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-all</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.1-jre</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.1.Final</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</build>
您能建议如何解决这个问题吗?
【问题讨论】:
-
@TechFree 我看到了。我在 pom.xml 中没有休眠依赖项。我尝试添加 jboss-deployment-structure.xml 但这没有帮助。
-
org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec和javax.persistence:persistence-api都应标记为<scope>provided</scope>。 -
我最终删除了这些
org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec和javax.persistence:persistence-api以及org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec,因为它们被证明是不必要的。删除部分后,该问题意外再次出现。最终解决该问题的方法是从 org.apache.directory.api:api-all中排除org.apache.servicemix.bundle:org.apache.servicemix.bundles.dom4j并添加依赖项org.dom4j:dom4j(版本 2.1.1)。希望这会对某人有所帮助。
标签: java maven jakarta-ee wildfly