简体   繁体   English

Apache-POI:“无法解析符号”

[英]Apache-POI: “Cannot resolve symbol”

I want to use Apache POI to read and write Excel files in Java. 我想使用Apache POI在Java中读写Excel文件。 I am using Maven for the dependencies, but when importing I get the error: Cannot resolve symbol usermodel for example. 我使用Maven作为依赖项,但是在导入时出现错误: Cannot resolve symbol usermodel

These are my imports: 这些是我的进口:

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

This is my POM: 这是我的POM:

<?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>groupId</groupId>
<artifactId>Boekhouding</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-3.17</artifactId>
        <version>3.10-FINAL</version>
        <systemPath>${basedir}\src\lib\poi-3.17.jar</systemPath>
    </dependency>


    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${apache.poi.version}</version>
        <systemPath>${basedir}\src\lib\poi-ooxml-3.17.jar</systemPath>
    </dependency>
</dependencies>
</project>

change your dependencies with that. 改变你的依赖。 This is more suitable and enough for solution. 这更适合解决方案。

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.17</version>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM