【问题标题】:Maven: resource binary changes file size after buildMaven:资源二进制文件在构建后更改文件大小
【发布时间】:2013-10-30 07:05:44
【问题描述】:

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

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

当我构建我的应用程序时,证书的文件大小会增加几 KB。这使其无效。我也看到 .jks 证书也发生了同样的情况。

我已经验证了pre-build证书的有效性,并用同样的方法确认了post-build证书的无效。

谁能告诉我为什么文件大小会发生变化以及为什么不简单地将其复制到 WAR 中?

感谢您的帮助。

【问题讨论】:

  • 您应该向我们展示您的 pom,或者可以重现问题的 pom。

标签: java google-app-engine maven ssl javapns


【解决方案1】:

另一种解决方案是通过添加以下配置来禁用对整个项目的 .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>

【讨论】:

  • 我也在 maven-war-plugin 中进行了过滤。为 p12 文件禁用它解决了这个问题。
【解决方案2】:

似乎 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>

这允许正确读取证书并解决 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)

【讨论】:

    【解决方案3】:

    我通过将“.p12”文件上移一个目录解决了这个问题。因此,我没有将其保存在 WEB-INF 中,而是将其移至“webapp”目录。那里没有过滤。

    【讨论】:

      猜你喜欢
      • 2012-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多