我正在使用生成的证书来解决问题,我用它来连接苹果推送服务.当生成的p12文件位于我的src/main/java文件夹中时,一切正常,但我将其移动到src/main/resources,并决定停止处理以下错误:
DerInputStream.getLength(): lengthTag=111, too big.
Run Code Online (Sandbox Code Playgroud)
要了解更多细节:我正在使用notnoop推送通知库,并按照Ray Wenderlich的教程生成证书.之后,我习惯按照命令生成一个p12文件,以便在java中使用:
openssl x509 -in aps_development.cer -inform DER -out aps_development.pem -outform PEM
openssl pkcs12 -nocerts -in single.p12 -out single.pem
openssl pkcs12 -export -inkey single.pem -in aps_development.pem -out dual.p12
Run Code Online (Sandbox Code Playgroud)
之后我将dual.p12移动到我的java项目中.首先,文件位于我的/ src/main/java文件夹中,让我们说com.company.push.certificates(当请求文件的代码处于时com.company.push).我通过使用请求输入流
InputStream stream = this.getClass().getResourceAsStream("certificates/dual.p12");
Run Code Online (Sandbox Code Playgroud)
这在开发中工作正常,但在构建项目时没有(使用maven),这就是为什么我使用完全相同的包将资源移动到资源文件夹.资源仍然被发现,但现在我得到了上述java.io.IOException
有谁知道这可能导致什么?
Ps:当我将文件移回src/main/java中的包时,一切正常,因此证书似乎是有效的.
我在从 src/main/resources/lib 文件夹分发 dll 的 maven 项目中遇到问题。
该项目使用 maven-assembly-plugin 构建为具有依赖项的单个 jar。
不幸的是,maven 进程在复制过程中破坏了我的 dll 库,因此它们对应用程序不再有用。
我看过诸如资源过滤之类的概念。
这是我的相关 pom.xml
有没有人有任何想法?
我想我需要做这样的事情,但到目前为止它对我不起作用。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<resources>
<resource>
<directory>${basedir}/src/main/resources/lib</directory>
<filtering>false</filtering>
</resource>
</resources>
<archive>
<manifest>
<mainClass>de.bochumuniruhr.psy.bio.behaviourcoder.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我的最终解决方案(基于以下答案):
谢谢你的好答案。我最终得到了不需要扩展 maven-resources-plugin 配置的答案。我将二进制文件放在文件src/main/resources/unfiltered-resources夹中,因为我需要过滤其他资源。
这是源代码的链接。
以下是我在撰写本文时的最终工作 pom。
<build>
<finalName>BehaviourCoder_${git.build.time}_${git.commit.id.describe-short}</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>${basedir}/src/main/unfiltered-resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<injectAllReactorProjects>true</injectAllReactorProjects>
<dateFormat>yyyy-MM-dd_HHmmss</dateFormat>
<dateFormatTimeZone>UTC</dateFormatTimeZone>
</configuration> …Run Code Online (Sandbox Code Playgroud)