简体   繁体   English

Maven 快照依赖

[英]Maven snapshot dependency

There are two projects Pm and Pd.有两个项目 Pm 和 Pd。 They are separate Jenkins projects that can be built separately.它们是单独的 Jenkins 项目,可以单独构建。 Pm depends on Pd and it is a snapshot version dependency. Pm 依赖于 Pd,它是一个快照版本依赖。

Recently an issue occurs during building Pm.最近在构建Pm的过程中出现了一个问题。 It complains of not being able to download Pd jar from the remote repository with this error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException它抱怨无法从远程存储库下载 Pd jar 并出现以下错误:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException

Though the error suggests a possible issue with JVM certificate, it looks like not as other jars from the same remote repository can be downloaded successfully.尽管该错误表明 JVM 证书可能存在问题,但似乎无法成功下载同一远程存储库中的其他 jar。

If manually builds Pd first (local repository has a Pd snapshot jar and remote repository has the deployed timestamped Pd jar), then builds Pm, it works OK as it does not try to download Pd jar from remote repository.如果先手动构建 Pd(本地存储库有 Pd 快照 jar,远程存储库有部署的带时间戳的 Pd jar),然后构建 Pm,它可以正常工作,因为它不会尝试从远程存储库下载 Pd jar。
But a few days later, without any change of Pd, when Pm builds (this time Pd is not manually built), it invokes a packaging of Pd dynamically which I didn't figure out why.但是几天后,在 Pd 没有任何变化的情况下,当 Pm 构建时(这次 Pd 不是手动构建的),它会动态调用 Pd 的包装,我不知道为什么。 In this case, local repository has the Pd snapshot jar from last time, and the remote repository has a newly deployed timestamp Pd jar.在这种情况下,本地存储库具有上次的 Pd 快照 jar,远程存储库具有新部署的时间戳 Pd jar。 It then tries to download this new timestamp Pd jar from remote repository and cannot download the jar with error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException然后它尝试从远程存储库下载这个新的时间戳 Pd jar 并且无法下载该 jar 并出现错误:PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException

Please help with the following questions (not sure if it matters: the maven version used is 3.6.3):请帮助解决以下问题(不确定是否重要:使用的 maven 版本是 3.6.3):

  1. Is maven supposed to build the dependency on the fly or just use the latest one in the repositories? maven 应该动态构建依赖关系还是只使用存储库中的最新依赖关系? For example, Pm depends on Pd.例如,Pm 取决于 Pd。 Will Pm just uses the latest version of Pd in repository (and if Pd jar is not available, it complains cannot find Pd), or will Pm builds Pd each time when Pm builds? Pm 会只使用存储库中最新版本的 Pd(如果 Pd jar 不可用,它会抱怨找不到 Pd),还是每次 Pm 构建时 Pm 都会构建 Pd? What decides which behavior?什么决定了哪种行为? I observed the 2nd case (each time Pm builds, it packages a new Pd jar in remote repository without installing Pd jar to local repository) and I didn't figure out why----what makes it generate a new Pd jar (only the timestamped Pd jar deployed to remote repository without a new snapshot Pd jar in local repository) and do not use the latest Pd jar?我观察到了第二种情况(每次 Pm 构建时,它都会在远程存储库中打包一个新的 Pd jar,而没有将 Pd jar 安装到本地存储库中),但我不明白为什么——是什么让它生成了一个新的 Pd jar(仅部署到远程存储库的时间戳 Pd jar,本地存储库中没有新的快照 Pd jar)并且不使用最新的 Pd jar?

  2. Why cannot the newly generated Pd jar be downloaded with an "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException"?为什么不能下载新生成的 Pd jar 并显示“PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException”? Any clue what could be wrong?任何线索可能是错误的? As mentioned earlier, all other jars can be downloaded successfully from the same remote repository except this newly generated Pd jar, so it seems not a JVM certificate issue in building machine.如前所述,除了这个新生成的 Pd jar 之外,所有其他 jar 都可以从同一个远程存储库成功下载,因此似乎不是构建机器中的 JVM 证书问题。

The error indicates problems with SSL certificates.该错误表明 SSL 证书存在问题。 I guess the remote repository is accessible via https, and it may have changed it's certificate so the client does no longer trust the server and refuses to communicate.我猜远程存储库可以通过 https 访问,并且它可能已经更改了它的证书,因此客户端不再信任服务器并拒绝通信。 It need not even be the remote repository server.它甚至不需要是远程存储库服务器。 Your organization setting up a proxy server that mangles SSL connections is sufficient for this error to occur.您的组织设置了破坏 SSL 连接的代理服务器就足以发生此错误。

You describe the problem does not exist if the projects get built locally - this is when the repository server does not have to be contacted which supports above theory.如果项目是在本地构建的,则您描述的问题不存在 - 这是当不必联系支持上述理论的存储库服务器时。

Check a tutorial like https://resources.weboffice.vertigis.com/Documentation/WebOffice102/EN/howto_install_certs_to_truststore.htm (there are many out there) how to add your repository's public certificate to your maven's truststore.检查像https://resources.weboffice.vertigis.com/Documentation/WebOffice102/EN/howto_install_certs_to_truststore.htm这样的教程(有很多)如何将您的存储库的公共证书添加到您的 maven 的信任库。

But to answer your questions:但是要回答您的问题:

  1. Maven is not supposed to automatically build the dependencies unless they are subprojects of the current project (this refers to multi module projects ). Maven 不应该自动构建依赖项,除非它们是当前项目的子项目(这是指多模块项目)。 It will try to access the already compiled dependencies from the repository, preferring the local one (which also caches) above the remote.它将尝试从存储库访问已编译的依赖项,更喜欢在远程之上的本地(也缓存)。

  2. Did you verify Maven still downloads other dependencies?您是否验证了 Maven 仍然下载其他依赖项? After all they get cached, so unless you clear the cache or modify your dependencies (name/version) there is no need to do that again - and you mention this recently occurred.毕竟它们被缓存了,所以除非您清除缓存或修改您的依赖项(名称/版本),否则无需再次执行此操作 - 您提到了最近发生的情况。 To clean the cache check out https://stackoverflow.com/a/22671261/4222206要清理缓存,请查看https://stackoverflow.com/a/22671261/4222206

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM