欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Maven打包后为何文件大小改变了

程序员文章站 2022-07-13 09:58:02
...

项目中使用了X.509证书,用Maven打包后,测试时报错:

java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Invalid BER/DER data (too huge?)

 

查找了好一会儿原因,才发现证书文件确实变huge了。这是怎么导致的呢,因为resource使用了filter, maven更改了文件内容,解决方法如下:

 

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>cer</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>

 

以下摘自maven文档

 

Warning: Do not filter files with binary content like images! This will most likely result in corrupt output.

 

If you have both text files and binary files as resources it is recommended to have two separated folders. One folder src/main/resources (default) for the resources which are not filtered and another folder src/main/resources-filtered for the resources which are filtered.

 

Binary filtering