Maven:资源二进制文件在构建后更改文件大小

sbs*_*ith 21 java ssl google-app-engine maven javapns

我正在使用appengine-maven-plugin来构建我的Java Google App Engine项目.

我在WEB-INF子文件夹中包含.p12证书

当我构建我的应用程序时,证书的文件大小增加了几KB.这使它无效.我也看到过.jks证书也是如此.

我已经验证了预构建证书的有效性,并使用相同的方法来确认构建后证书的无效性.

任何人都可以告诉我为什么文件大小正在改变以及为什么它不是简单地复制到WAR?

谢谢你的帮助.

小智 31

另一种解决方案是通过添加以下配置来禁用整个项目中.p12文件的过滤:

<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-resources-plugin</artifactId>                
      <configuration>
        <nonFilteredFileExtensions>
          <nonFilteredFileExtension>p12</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
      </configuration>
    </plugin>
  </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)


sbs*_*ith 9

似乎maven正在对我的证书文件应用过滤

http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

解决方案是禁用它

<resource>
    <directory>${basedir}/src/main/webapp/certs</directory>
    <filtering>false</filtering>
    <targetPath>WEB-INF/classes</targetPath>
</resource>
Run Code Online (Sandbox Code Playgroud)

这样可以正确读取证书并在JavaPNS中解决以下异常

Validating keystore reference: VALID  (keystore was found)
Verifying keystore content: javapns.communication.exceptions.KeystoreException:
Keystore exception: DerInputStream.getLength(): lengthTag=111, too big. at javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:178)
Run Code Online (Sandbox Code Playgroud)