1. 介绍

介绍如何使用tika-parser的插件 可以抽取文件的元数据和内置文本信息,支持pdf、doc、ppt、excel、gif、jpeg等多种格式的文件

tika-parser的插件

2. 使用

gradle中增加,注意tika使用很多依赖库,会与应用系统的依赖类库冲突、建议增加exclude module来回避冲突。

    implementation('org.yunchen.gb:gb-plugin-tika-parser:1.2.0') {
             exclude module: "ehcache-core"
             exclude module: "poi"
             exclude module: "poi-ooxml"
             exclude module: "poi-ooxml-schemas"
             exclude module: "poi-scratchpad"
             exclude module: "jackson-core"
             exclude module: "javax.ws.rs-api"
             }

在controller或service中注入TikaService,并调用相关的方法

    @Autowired
    TikaService tikaService

使用操作

String parseFile(File file)