Maven阴影tika-app返回空字符串

时间:2019-02-28 13:28:12

标签: java apache-tika maven-shade-plugin

我正在使用tika-app-1.20.jar从文件中提取元数据和内容。我为Tika着色的原因是要删除已经构建的项目中相互冲突的依赖项。

带阴影的jar可以很好地解决新的带阴影名称的导入问题,但随后对所有文件返回“ EmptyParser”,导致没有内容被解析。

    <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>1.20</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>3.2.1</version>
            <configuration>
                <createSourcesJar>true</createSourcesJar>
        <relocations>
          <relocation>
            <pattern>org.apache.tika</pattern>
            <shadedPattern>com.test1.tika</shadedPattern>
          </relocation>
        </relocations>

        <filters>
          <filter>
              <artifact>*:*</artifact>
              <excludes>
                  <exclude>META-INF/*.SF</exclude>
                  <exclude>META-INF/*.RSA</exclude>
                  <exclude>META-INF/*.DSA</exclude>
              </excludes>
          </filter>
      </filters>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

</project>

我删除了 .SF, .RSA,* DSA,以删除无效的签名摘要错误。我的直觉是,在此过程中删除了一些属性文件,该属性文件将解析器映射为文件类型。

0 个答案:

没有答案