我安装了安全证书,但我遇到了问题。当我用
运行我的代码时mvn exec:java -Dexec.mainClass="com.myproject.MyClass"
它工作正常。但是当我尝试在JAR中打包东西时,用以下命令运行它:
java -jar MyProject.jar
我得到了
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
... 32 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 38 more
我用:
创建jarmvn clean install jar:jar
在与jar相同的级别上,我有一个名为lib
的目录,而在lib
中我拥有所有依赖项。依赖项被添加到我的jar中的MANIFEST.MF文件中,它们的路径是正确的,行不是太长(每行依赖一个)。
Maven和Java使用相同的JDK。它们通常也应该在类路径上具有相同的依赖关系。但似乎java -jar
忽略了证书。
有人可以解释为什么会这样吗?
谢谢。