我无法导入org.springframework.batch.item.excel.poi.PoiItemReader。它显示以下错误。
我的错误:
我的Pom文件:
npm init
npm i yargs --save
导入org.springframework.batch.item.excel.poi.PoiItemReader无法解析。我在pom文件中明确提到了必需的依赖项。
我需要添加任何其他依赖吗?
答案 0 :(得分:1)
否,您不需要其他依赖项。 问题是远程Maven存储库中不存在 spring-batch-excel 。因此,您需要在本地Maven缓存中手动安装它。
要这样做:
1。查看春季批量扩展的来源
git clone git://github.com/spring-projects/spring-batch-extensions.git
2。进入spring-batch-excel模块的目录
cd spring-batch-extensions
cd spring-batch-excel
3。编译和测试,构建所有jars
mvn clean package
4。将模块jars安装到本地Maven缓存中
mvn install
现在 spring-batch-excel 存在于本地Maven缓存中。
来源:https://github.com/spring-projects/spring-batch-extensions
答案 1 :(得分:0)
您需要Excel的春季批量扩展。请参阅link
答案 2 :(得分:0)
我自己添加了以下依赖项来解决此问题。
<dependency>
<groupId>com.github.deanwong</groupId>
<artifactId>spring-batch-excel</artifactId>
<version>0.5.5</version>
</dependency>
这是我的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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.poc.springbatch.poc</groupId>
<artifactId>SpringBatch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringBatch</name>
<description>Spring Batch</description>
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<poi.version>3.11</poi.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.deanwong</groupId>
<artifactId>spring-batch-excel</artifactId>
<version>0.5.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>