简体   繁体   English

新的Maven依赖版本将pom而不是jar放入私有关系仓库中?

[英]New maven dependency version pulling pom, not jar into private nexus repo?

I'm upgrading some dependency versions I have in a java/maven/spring application, which is using our nexus repo as the central repository mirroring maven central. 我正在升级java / maven / spring应用程序中的某些依赖项版本,该应用程序使用我们的nexus存储库作为镜像maven Central的中央存储库。

I tried upgrading hibernate to it's newest version of 3.5.4-Final as listed: 我尝试将休眠模式升级到最新的3.5.4-Final版本,如下所示:

Hibernate newest release stable version Hibernate最新版本稳定版

And when I run maven install, I see in my nexus server that there is now 3.5.4-Final listed, but inside its directory there is only a pom.xml file for the project and none of it's associated JAR's. 而且,当我运行maven install时,在我的连接服务器上看到现在列出了3.5.4-Final,但是在其目录内仅存在该项目的pom.xml文件,并且都没有关联的JAR文件。

When I inspect the POM, I can see it's packaging is listed as POM and not JAR. 当我检查POM时,可以看到它的包装被列为POM而不是JAR。

Why is this, and how can I make maven take the jar packaged version of the library rather than just the POM? 为什么会这样,又如何使Maven接受库的jar打包版本而不是POM?

EDIT - mvn install error message posted: 编辑-发布的mvn安装错误消息:

[ERROR] Failed to execute goal on project app: Could not resolve dependencies for project com.app:app:war:16.2.1-SNAPSHOT: Failure to find org.hibernate:hibernate:jar:3.5.4-Final in http://ssp-nexus1.mynexus-server.com:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of company.nexus.mirror has elapsed or updates are forced -> [Help 1]

As mentioned in the link you provided 如您提供的链接中所述

Aggregator of the Hibernate Core modules. Hibernate Core模块的聚合器。

So, the artifact you linked is effectively a pom which aggregates (as a multimodule) other Hibernate artefacts. 因此,链接的工件实际上是一个pom ,它会聚合(作为多模块)其他Hibernate工件。

Instead, the hibernate-core artifact, as an example, can be found here , as a standard maven dependency (that is, a jar ). 相反,作为示例,可以在此处找到hibernate-core工件,作为标准的maven依赖项(即jar )。

By default dependencies have type jar, so if you add the maven coordinates (GAV) for a dependency that is instead of type pom, maven will then look up for it as a jar. 默认情况下,依赖项的类型为 jar,因此,如果您为依赖项(而不是pom类型)添加了Maven坐标(GAV),则maven会将其查找为jar。 So that's why you are getting the error mentioned in your edit. 这就是为什么您在编辑中遇到提到的错误。

You should remove its dependency from your pom and only add the hibernate dependency you effectively need. 您应该从pom中删除其依赖关系,而仅添加您实际需要的休眠依赖关系。 As a rule of thumb, add the dependency you explicitly use in your code (as import statements, for instance) or your configuration files, and let then maven take care of the required transitive dependencies, given that they will be available on your company repository, obviously. 根据经验,添加您在代码(例如,作为import语句)或配置文件中显式使用的依赖项,然后让maven处理所需的传递性依赖项,因为它们将在公司存储库中可用,显然。

Update 更新资料
Following your latest comments and feedback, here is a further explanation about why just changing the version of the existing Hibernate dependency you got to this issue: 根据您的最新评论和反馈,以下是有关为何仅更改此问题的现有Hibernate依赖版本的进一步说明:

  • The new 3.5.4-Final and the previous 3.2.7.ga version share the same groupId and artifactId on the Maven repository 新的3.5.4-Final和先前的3.2.7.ga版本在Maven存储库上共享相同的groupIdartifactId
  • However, the former has type pom (it's a pom file), while the latter has type jar (the default one) 但是,前者的类型为pom (这是一个pom文件),而后者的类型为jar (默认值)。
  • So, the previously existing version was working fine and changing the version of the dependency you switched it from jar to pom , breaking the maven resolution (which was looking for a jar for a version which instead was a pom ) 因此,先前存在的版本运行良好,并且将依赖项的版本从jar更改为pom ,从而打破了maven的分辨率(该版本正在寻找一个jar来代替一个pom的版本)
  • This mainly happened because you switched from a ga to a FINAL version. 这主要是因为您从ga版本切换到了FINAL版本。 For a further explanation about the difference between these versions, you can check this SO question and this one 有关这些版本之间差异的进一步说明,您可以检查此SO问题 问题

As a side note, I find a bit inconsistent that changing a version number also changes the dependency type, it might a point of debate, but if I were the Hibernate team, I would handle this version management differently. 附带说明一下,我发现不一致的是,更改版本号也会更改依赖项类型,这可能是一个争论点,但是如果我是Hibernate团队,我将以不同的方式处理此版本管理。

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

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