当前位置: 首页 > 知识库问答 >
问题:

Maven shade插件-无法执行目标

海雪松
2023-03-14

我一直在尝试重命名tika应用程序类。由于类路径上的重复类,存在加载冲突。当我尝试运行maven install-e时,它会抛出错误,我想使用

Apache.Tika组织

分类为

com.test1.tika

pom.xml文件如下所示

 <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>com.test1.tika</groupId>
  <artifactId>tika-app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>tika-app</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tika</groupId>
        <artifactId>tika-app</artifactId>
        <version>1.20</version>
    </dependency>
  </dependencies>


  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <createSourcesJar>true</createSourcesJar>
                <relocations>
                    <relocation>
                        <pattern>org.apache.tika.</pattern>
                        <shadedPattern>com.test1.tika.</shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

</project>

mvn package命令的错误如下:

null

共有1个答案

郑和泰
2023-03-14

将maven-compiler-plugin版本从2.3改为3.2.1解决了这个问题。

 类似资料: