reason: the Java file contained parse errors

今天用Maven打包项目时发生一个错误:
file: D:\workspace\echoo2.0-xxx-xxx-portal\src\main\java\com\echoo\service\impl\DecDataServiceImpl.java; reason: the Java file contained parse errors

打包报错显示这个类解析错误
在IDEA中没有任何错误提示

问题所在:
代码中用了jdk14的新特性,一个新的数据结构 record

	// 定义了一个record类型的对象
    private record Result(byte[] dataKeyByte, byte[] dataIvByte) {}

    private Result getResult(DeliveryEncKey deliveryEncKey) throws Exception {
        String dataKey = AESGCMUtil.decrypt(AESGCMUtil.hexStringToByteArray(deliveryEncKey.getEncryptionKey()),
                aesGCMConf.getMasterKey(), aesGCMConf.getMasterIv());
        String dataIV = AESGCMUtil.decrypt(AESGCMUtil.hexStringToByteArray(deliveryEncKey.getIv()),
                aesGCMConf.getMasterKey(), aesGCMConf.getMasterIv());
        byte[] dataKeyByte = AESGCMUtil.hexStringToByteArray(dataKey);
        byte[] dataIvByte = AESGCMUtil.hexStringToByteArray(dataIV);
        return new Result(dataKeyByte, dataIvByte);
    }

项目用的是jdk17,这是IDEA没有报错的原因,因为这个语法jdk17是完全支持的
在这里插入图片描述
但是用Maven打包或者编译时却报了无法解析的错
看了一下pom编译配置:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version> <!-- 使用与你的Maven版本兼容的最新版本 -->
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>

Maven的jdk版本

PS D:\workspace\xxxxx> mvn -version
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: D:\tools\apache-maven-3.9.1
Java version: 17.0.5, vendor: Oracle Corporation, runtime: D:\tools\JDK17
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

也找不到什么问题

这时候俺再仔细看了一下报错:
Caused by: net.revelc.code.impsort.ex.ImpSortException: file: D:\workspace\dm2.0-api-for-courier-admin-portal\src\main\java\com\hkt\it\ds\ruby\dmg\courieradmin\service\impl\DecDataServiceImpl.java; reason: the Java file contained parse errors

发现这个ImpSortException好像是一个第三方的异常,
仔细看了看pom文件,发现项目用了一个第三方插件impsort-maven-plugin

            <plugin>
                <groupId>net.revelc.code</groupId>
                <artifactId>impsort-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>sort-imports</id>
                        <goals>
                            <goal>sort</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                </executions>
            </plugin>

这个插件是他们用来做代码排序的,注释掉这个插件就build success了
在这里插入图片描述
垃圾插件!!!
去这个插件的官方文档看了看
在这里插入图片描述
1.9.0版本是2023-05-09日更新的
在这里插入图片描述
jdk14于2020年3月17日正式发布,它竟然不支持?
垃圾插件!!!

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值