EasyExcel莫名失效,映射到StudentInfoExcel中,属性都是null

EasyExcel莫名失效,映射到StudentInfoExcel中,属性都是null,经过一系列排查,是easyExcel版本未指定明确问题。2.2.6
项目中的结构是父子依赖的。这种方式本地没有问题,但是发布到服务器就还有原来的问题。
所以解决方式是在Excel类上加@Accessors(chain = false)

@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
@Accessors(chain = false)
public class StudentExcel implements Serializable {

    private static final long serialVersionUID = 3096634685988807546L;

    @ColumnWidth(18)
    @ExcelProperty(value = "*学生姓名", index = 0)
    private String realName;

    @ColumnWidth(20)
    @ExcelProperty(value = "*手机号", index = 1)
    private String telephone;

    @ColumnWidth(18)
    @ExcelProperty(value = "出生日期(年/月/日,例如 2021/10/10)", index = 2)
    @DateTimeFormat(pattern = ColumnFormatter.PATTERN_DATE)
    @JsonFormat(pattern = ColumnFormatter.PATTERN_DATE)
    private Date birthday;

    @ColumnWidth(10)
    @ExcelProperty(value = "性别(男/女)", index = 3)
    private String genderName;

    @ColumnWidth(25)
    @ExcelProperty(value = "公立学校(20字以内)", index = 4)
    private String publicSchool;

}
  1. 这个是顶层la-parent依赖
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.lookahead</groupId>
    <artifactId>la-parent</artifactId>
    <version>0.0.4-SNAPSHOT</version>
    <name>la-parent</name>
    <description>la-parent</description>
    <packaging>pom</packaging>

    <properties>
        <!-- base -->
        <java.version>1.8</java.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!-- maven -->
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <maven.test.skip>true</maven.test.skip>
        <maven.plugin.version>3.8.1</maven.plugin.version>
        <versions-maven-plugin.version>2.3</versions-maven-plugin.version>
        <!-- spring -->
        <spring-boot-dependencies.version>2.7.15</spring-boot-dependencies.version>
        <spring-cloud-dependencies.version>2021.0.5</spring-cloud-dependencies.version>
        <spring.cloud.alibaba.version>2021.0.4.0</spring.cloud.alibaba.version>
        <spring.plugin.version>2.0.0.RELEASE</spring.plugin.version>
        <spring-boot-maven-plugin.version>2.4.13</spring-boot-maven-plugin.version>
        <spring-cloud-commons.version>3.1.7</spring-cloud-commons.version>
        <!-- database -->
        <mybatis-spring-boot-starter.verion>2.3.1</mybatis-spring-boot-starter.verion>
        <mybatis-plus-boot-starter.version>3.4.2</mybatis-plus-boot-starter.version>
        <mybatis-plus-join-boot-starter.version>1.4.13</mybatis-plus-join-boot-starter.version>
        <dynamic-datasource.version>3.5.2</dynamic-datasource.version>
        <mysql-connector-java.version>8.0.28</mysql-connector-java.version>
        <!-- others -->
        <alibaba-nacos.version>2.2.9.RELEASE</alibaba-nacos.version>
        <guava.version>33.0.0-jre</guava.version>
        <apache.commons-lang3.version>3.13.0</apache.commons-lang3.version>
        <commons-collections4.version>4.4</commons-collections4.version>
        <fastjson.version>2.0.38</fastjson.version>
        <httpclient.version>4.5.14</httpclient.version>
        <hutool-all.version>5.8.28</hutool-all.version>
        <validation-api.version>2.0.1.Final</validation-api.version>
        <jakarta.validation-api.version>3.0.2</jakarta.validation-api.version>
        <hibernate-validator.version>6.2.0.Final</hibernate-validator.version>
        <caffeine.version>3.1.8</caffeine.version>
        <xxl-job-core.version>2.4.0</xxl-job-core.version>
        <easyexcel.version>2.2.6</easyexcel.version>
    </properties>

    <modules>
        <module>parent-common</module>
        <module>parent-database</module>
        <module>parent-cache</module>
        <module>parent-apidoc</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot-dependencies.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud-dependencies.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring.cloud.alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${fastjson.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${httpclient.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${apache.commons-lang3.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>${commons-collections4.version}</version>
            </dependency>
            <dependency>
                <groupId>cn.hutool</groupId>
                <artifactId>hutool-all</artifactId>
                <version>${hutool-all.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot-maven-plugin.version}</version>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>UTF-8</encoding>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions-maven-plugin.version}</version>
                <configuration>
                    <generateBackupPoms>false</generateBackupPoms>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>


    <distributionManagement>
        <repository>
            <id>custom_release</id>
            <url>http://192.168.110.200:8081/repository/custom_release/</url>
        </repository>
        <snapshotRepository>
            <id>custom_snapshot</id>
            <url>http://192.168.110.200:8081/repository/custom_snapshot/</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>custom_group</id>
            <name>custom_group</name>
            <url>http://192.168.110.200:8081/repository/custom_group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>custom_group</id>
            <name>custom_plugin_group</name>
            <url>http://192.168.110.200:8081/repository/custom_group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

2、 这个是中间la-server中作为父依赖的pom.xml

<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.lookahead</groupId>
        <artifactId>la-parent</artifactId>
        <version>0.0.4-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository 指定依赖的父项目在远程仓库中-->
    </parent>

    <artifactId>la-server</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>la-server</name>
    <url>http://maven.apache.org</url>

    <modules>
        <module>api</module>
        <module>la-sys</module>
        <module>la-order</module>
        <module>la-resource</module>
        <module>la-product</module>
        <module>la-convert</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-boot-maven-plugin.version>2.4.13</spring-boot-maven-plugin.version>
        <captcha.version>1.6.2</captcha.version>
    </properties>

    <distributionManagement>
        <repository>
            <id>custom_release</id>
            <url>http://192.168.110.200:8081/repository/custom_release/</url>
        </repository>
        <snapshotRepository>
            <id>custom_snapshot</id>
            <url>http://192.168.110.200:8081/repository/custom_snapshot/</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>custom_group</id>
            <name>custom_group</name>
            <url>http://192.168.110.200:8081/repository/custom_group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>custom_group</id>
            <name>custom_plugin_group</name>
            <url>http://192.168.110.200:8081/repository/custom_group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

3、这个是api依赖

<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.lookahead</groupId>
        <artifactId>la-server</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>api</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>

    <name>api</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- api doc -->
        <dependency>
            <groupId>org.lookahead</groupId>
            <artifactId>parent-apidoc</artifactId>
            <version>0.0.4-SNAPSHOT</version>
        </dependency>
        <!--小工具-->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
        </dependency>
        <!--xml解析-->
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>2.11.1</version>
        </dependency>
        <!--excel,api包中引入了easyexcel依赖,但是没有直接指定版本号,他依赖于父项目la-server,但是la-server中也没有版本号管理,依赖于在上一层la-parent,但是la-server和la-parent不在一个项目下,所以la-server的parent标签中要有指定依赖的父项目在远程仓库中-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>${easyexcel.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

4、这个是使用easyexcel的项目依赖,可以看到这里没有直接引入easyexcel,而是通过api包引入的

<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.lookahead</groupId>
        <artifactId>la-server</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>la-sys</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>

    <name>la-sys</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <commons-io.version>2.16.1</commons-io.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.lookahead</groupId>
            <artifactId>api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.lookahead</groupId>
            <artifactId>parent-cache</artifactId>
            <version>0.0.4-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.lookahead</groupId>
            <artifactId>parent-database</artifactId>
            <version>0.0.4-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
            <version>4.0.4</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <!-- xxl-job-core -->
        <dependency>
            <groupId>com.xuxueli</groupId>
            <artifactId>xxl-job-core</artifactId>
            <version>${xxl-job-core.version}</version>
        </dependency>
        <!-- 解决多网卡问题 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-commons</artifactId>
            <version>${spring-cloud-commons.version}</version>
        </dependency>
        <!-- Captcha -->
        <dependency>
            <groupId>com.github.whvcse</groupId>
            <artifactId>easy-captcha</artifactId>
            <version>${captcha.version}</version>
        </dependency>
        <!--aliyun-api-->
        <dependency>
            <groupId>com.aliyun.oss</groupId>
            <artifactId>aliyun-sdk-oss</artifactId>
            <version>3.17.1</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>dysmsapi20170525</artifactId>
            <version>2.0.23</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-openapi</artifactId>
            <version>0.2.8</version>
            <scope>compile</scope>
        </dependency>
        <!--WEB-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>
        <!-- 第三方登陆 -->
        <dependency>
            <groupId>me.zhyd.oauth</groupId>
            <artifactId>JustAuth</artifactId>
            <version>1.15.8</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>custom_group</id>
            <name>custom_group</name>
            <url>http://192.168.110.200:8081/repository/custom_group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>custom_group</id>
            <name>custom_plugin_group</name>
            <url>http://192.168.110.200:8081/repository/custom_group/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <finalName>${project.artifactId}</finalName>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**.*</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot-maven-plugin.version}</version>
                <configuration>
                    <mainClass>org.lookahead.sys.LaSysApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <!--suppress UnresolvedMavenProperty -->
                                <copy overwrite="true"
                                      tofile="${session.executionRootDirectory}/target/${project.name}.jar"
                                      file="${project.build.directory}/${project.artifactId}.jar" />
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

la-parent(la-parent只有版本管理,一些工具类、common包等)
la-server(没有版本号管理,依赖于parent,<relativePath/>)
	la-api(引入了easyexcel,没有指定版本号)
	la-sys(使用了easyexcel,引入了la-api)

依赖的父项目la-parent在远程仓库中
注意:
1、当你没有设置 ,并且父项目并不在远程仓库中时,Maven 无法找到父项目的 pom.xml 文件。此时,依赖关系和插件继承都将无法生效。

如果父项目发布在私有仓库或中央仓库中,则 可以为空,这样 Maven 会直接从仓库中下载父项目的 pom.xml。但如果父项目没有发布到仓库中,并且没有指定正确的相对路径,那么子项目将无法解析父项目的配置。
2、如果不写,默认…/pom.xml。
3、可以指定路径。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值