1

我正在尝试POI将 word 文件转换为 txt 文件,但是当我使用org.apache.poi.xwpf.usermodel.XWPFDocument它时告诉我“无法解析 xwpf”

我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
 <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>convert</groupId>
<artifactId>convertor</artifactId>
<version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.10-FINAL</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
        </dependency>

    </dependencies>

当我运行clean & package它给我success。我该如何解决这个问题?

4

1 回答 1

7

根据Apache POI 组件页面,因为XWPF您需要poi-ooxmlmaven 工件作为依赖项

因此,您的 pom 将看起来像这样:

<properties>
    <poi.version>3.10-FINAL</poi.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>${poi.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${poi.version}</version>
    </dependency>
</dependencies>
于 2014-05-05T12:55:33.853 回答