[英]I am using two libraries in one project and some of the jar files are conflicting.How do I resolve?
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.aksw.deer.plugin</groupId>
<artifactId>plugin-starter</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<!-- @todo Customize this value 👇 -->
<name> Simple Example Plugin</name>
<!-- @todo Customize this value 👇 -->
<description> Plugin Starter</description>
<!-- @todo Customize this value 👇 -->
<scm>
<!-- @todo Customize this value 👇 -->
<url>https://github.com/abc</url>
<!-- @todo Customize this value 👇 -->
<connection>scm:git:https://github.com/abc.git</connection>
<tag>HEAD</tag>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- @todo Customize this value 👇 -->
<plugin.id>OntologyMatchingPlugin</plugin.id>
<!-- @todo Customize this value 👇 -->
<plugin.class>org.aksw.deer.plugin.example.OntologyMatchingPlugin</plugin.class>
<!-- @todo Customize this value 👇 -->
<plugin.version>1.0.0</plugin.version>
<!-- @todo Customize this value 👇 -->
<plugin.dependencies />
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<deer.version>2.3.0</deer.version>
</properties>
<repositories>
<repository>
<id>data-local</id>
<name>data</name>
<url>file://${project.basedir}/repo</url>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>maven.aksw.internal</id>
<name>abcs</name>
<url>https://maven.aksw.org/repository/internal/</url>
</repository>
<repository>
<id>maven.aksw.snapshots</id>
<name>University , AKSW Maven2 Snapshot Repository</name>
<url>https://maven.aksw.org/repository/snapshots/</url>
</repository>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>https://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.source}</release>
<encoding>${project.build.sourceEncoding}</encoding>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.pf4j</groupId>
<artifactId>pf4j</artifactId>
<version>3.0.1</version>
</annotationProcessorPath>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>org.pf4j.processor.ExtensionAnnotationProcessor
</annotationProcessor>
</annotationProcessors>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>7.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>aggregate</id>
<phase>package</phase>
<goals>
<goal>aggregate-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<includeDependencySources>true</includeDependencySources>
<dependencySourceIncludes>
<dependencySourceInclude>org.aksw.deer:*</dependencySourceInclude>
<dependencySourceInclude>org.aksw.faraday_cage:*</dependencySourceInclude>
</dependencySourceIncludes>
<links>
<link>https://jena.apache.org/documentation/javadoc/jena</link>
</links>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<forkCount>0</forkCount>
<argLine>-Xms256m -Xmx8G</argLine>
<testFailureIgnore>false</testFailureIgnore>
<skipTests>false</skipTests>
<useManifestOnlyJar>false</useManifestOnlyJar>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.artifactId}-${project.version}-plugin</finalName>
<appendAssemblyId>false</appendAssemblyId>
<attach>false</attach>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Plugin-Id>${plugin.id}</Plugin-Id>
<Plugin-Version>${plugin.version}</Plugin-Version>
<Plugin-Provider>${plugin.provider}</Plugin-Provider>
<Plugin-Class>${plugin.class}</Plugin-Class>
<Plugin-Dependencies>${plugin.dependencies}</Plugin-Dependencies>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<version>2.8.2</version>
</plugin>
</plugins>
</build>
<dependencies>
<!-- For depending of Logmap -->
<dependency>
<groupId>uk.ox.logmap</groupId>
<artifactId>logmap-matcher</artifactId>
<version>4.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version> <scope>test</scope> </dependency> -->
<!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId>
<version>1.6.4</version> </dependency> -->
<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-distribution -->
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>5.1.19</version>
</dependency>
<!-- <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId>
<version>2.7</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <version>2.7</version> <scope>test</scope>
</dependency> -->
<dependency>
<groupId>org.aksw.deer</groupId>
<artifactId>deer-core</artifactId>
<version>${deer.version}</version>
<!-- !!! VERY IMPORTANT -->
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>httpclient</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>httpclient</groupId>
<artifactId>httpclient-cache</artifactId>
</exclusion>
<exclusion>
<groupId>httpclient</groupId>
<artifactId>httpclient-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
I'm getting error as:我收到错误消息:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.ja
va:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.pf4j.DefaultPluginFactory.create(DefaultPluginFactory.java:64)
at org.pf4j.PluginWrapper.getPlugin(PluginWrapper.java:79)
at org.pf4j.AbstractPluginManager.startPlugins(AbstractPluginManager.java:331)
at org.aksw.deer.DeerController.<clinit>(DeerController.java:98)
Caused by: java.lang.ClassCastException: class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to class jav
ax.xml.parsers.DocumentBuilderFactory (org.apache.xerces.jaxp.DocumentBuilderFactoryImpl is in unnamed module of loader 'app
'; javax.xml.parsers.DocumentBuilderFactory is in unnamed module of loader org.pf4j.PluginClassLoader @332796d3)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:191)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:44
)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:510)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:450)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:257)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:560)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.aksw.deer.plugin.example.KGMatchingPlugin.<clinit>(KGMatchingPlugin.java:10)
... 8 more
You can relocate classes in maven: maven class relocation您可以重定位 maven 中的类: maven class 重定位
The best way for finding conflict in your pom file is using:在 pom 文件中查找冲突的最佳方法是使用:
mvn dependency:tree > somefile.txt
or或者
mvn dependency:tree -DoutputFile=myFile.dot -DoutputType=dot
then you can search for a specific library and you will be able to find out if there is any duplicate library with a different version in your dependency.然后您可以搜索特定的库,您将能够找出您的依赖项中是否有任何具有不同版本的重复库。 Also, The
verbose
mode tells the tree plugin to show dependencies that are duplicates of another or in conflict with another's version.此外,
verbose
模式告诉树插件显示与另一个重复或与另一个版本冲突的依赖项。
mvn dependency:tree -Dverbose
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.