如何将org.apache.tika源集成到我的项目中?

时间:2012-02-06 15:21:39

标签: java maven apache-tika

我已经下载了Apache Tika源文件夹,我已经安装了Maven。然后通过命令行(mvn install)我安装了Tika:

[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Apache Tika parent .................................... SUCCESS [4:20.656s]
[INFO] Apache Tika core ...................................... SUCCESS [2:26.466s]
[INFO] Apache Tika parsers ................................... SUCCESS [3:27.711s]
[INFO] Apache Tika application ............................... SUCCESS [1:23.548s]
[INFO] Apache Tika OSGi bundle ............................... SUCCESS [3:34.223s]
[INFO] Apache Tika ........................................... SUCCESS [6.217s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL

但现在我不知道在我的项目中使用Tika的下一步是什么。实际上我不知道如何在我的项目中添加Tika。

我使用Tika源代替jar文件的原因是我想将farsi.ngp文件添加到Tika的languageIdentification。我已添加farsi.ngp并由Maven构建Tika,但现在我不知道下一步是什么。我必须在项目中添加什么?

1 个答案:

答案 0 :(得分:2)

我阅读了this页面,以下是我的建议:

修改代码或添加.ngp文件并构建代码后,必须获取这些构建工件:

 tika-core/target/tika-core-1.0.jar
 tika-parsers/target/tika-parsers-1.0.jar

无论您在申请中何处使用tika,都要将2个tika罐及其附属罐子放入类路径中。例如,如果您在应用程序中使用ant,则将其添加到构建文件中:

<classpath>
  ... <!-- your other classpath entries -->
  <pathelement location="path/to/tika-core-1.0.jar"/>
  <pathelement location="path/to/tika-parsers-1.0.jar"/>
  <pathelement location="path/to/commons-logging-1.1.1.jar"/>
  <pathelement location="path/to/commons-compress-1.0.jar"/>
  <pathelement location="path/to/pdfbox-1.0.0-incubating.jar"/>
  <pathelement location="path/to/fontbox-1.0.0-incubator.jar"/>
  <pathelement location="path/to/jempbox-1.0.0-incubator.jar"/>
  <pathelement location="path/to/poi-3.6.jar"/>
  <pathelement location="path/to/poi-scratchpad-3.6.jar"/>
  <pathelement location="path/to/poi-ooxml-3.6.jar"/>
  <pathelement location="path/to/poi-ooxml-schemas-3.6.jar"/>
  <pathelement location="path/to/xmlbeans-2.3.0.jar"/>
  <pathelement location="path/to/dom4j-1.6.1.jar"/>
  <pathelement location="path/to/xml-apis-1.0.b2.jar"/>
  <pathelement location="path/to/geronimo-stax-api_1.0_spec-1.0.jar"/>
  <pathelement location="path/to/tagsoup-1.2.jar"/>
  <pathelement location="path/to/asm-3.1.jar"/>
  <pathelement location="path/to/log4j-1.2.14.jar"/>
  <pathelement location="path/to/metadata-extractor-2.4.0-beta-1.jar"/>
</classpath>

希望这会对你有所帮助。