【maven】Maven打包后为何文件大小改变了
项目中使用了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> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <configuration> <encoding>UTF-8</encoding> <nonFilteredFileExtensions> <nonFilteredFileExtension>pfx</nonFilteredFileExtension> <nonFilteredFileExtension>crt</nonFilteredFileExtension> <nonFilteredFileExtension>cer</nonFilteredFileExtension> <nonFilteredFileExtension>key</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.