gpt4 book ai didi

maven-2 - Maven 未下载快照

转载 作者:行者123 更新时间:2023-12-02 11:04:57 25 4
gpt4 key购买 nike

我正在尝试使用位于本地网络中的存储库设置 Maven,并且我已经设置了一个用于快照的存储库和一个用于发布的存储库(均为 apache archiva)。

从发布存储库下载软件包效果很好。但是,当我尝试从快照存储库加载 SNAPSHOT 版本时,当我尝试下载我自己部署的 SNAPSHOT 时,我不断收到错误:

[INFO] ------------------------------------------------------------------------  
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) my.company:product2:jar.lastUpdated:0.0.2-SNAPSHOT

Try downloading the file manually from the project website.
[...]

Path to dependency:
1) my.company:product1:war:0.0.1-SNAPSHOT
2) my.company:product2:jar.lastUpdated:0.0.2-SNAPSHOT

----------
1 required artifact is missing.

for artifact:
my.company:product1:war:0.0.1-SNAPSHOT

from the specified remote repositories:
my-internal (http://my-repo:8080/archiva/repository/internal),
central (http://repo1.maven.org/maven2),
my-snapshots (http://my-repo:8080/archiva/repository/snapshots),

该软件包在快照存储库中可用,网络已连接,登录工作正常。

我的 pom.xml 看起来像这样:

 [...]
<repositories>
<repository>
<id>my-snapshots</id>
<name>my name Snapshots Repository</name>
<url>http://my-snapshots:8080/archiva/repository/snapshots</url>
<snapshots>
<enabled/>
<updatePolicy/>
<checksumPolicy/>
</snapshots>
</repository>
<repository>
<id>my-internal</id>
<name>my name internal Repository</name>
<url>http://my-repo:8080/archiva/repository/internal</url>
</repository>
</repositories>
[...]

<dependency>
<groupId>my.company</groupId>
<artifactId>frontend-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
<type>jar.lastUpdated</type>
</dependency>
[...]

我还检查了从快照存储库下载的 maven-metadata.xml:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>my.company</groupId>
<artifactId>product2</artifactId>
<version>0.0.2-SNAPSHOT</version>
<versioning>
<snapshot>
<buildNumber>7</buildNumber>
<timestamp>20090824.130209</timestamp>
</snapshot>
<lastUpdated>20090824130209</lastUpdated>
</versioning>
</metadata>

它显示了正确的日期和时间戳(存储库中存在包含此时间戳的包)。

我是否遗漏了有关存储库设置或快照概念的内容?有人遇到同样的问题吗?或者有人知道有关快照和存储库的一些详细文档吗?

最佳答案

my-app 的依赖声明是什么样的?我希望它看起来像这样:

<dependency>
<groupId>my.company</groupId>
<artifactId>product2</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>

从错误来看,它似乎是由原型(prototype)生成的,并添加了lastUpdated类型。如果是这种情况,删除 lastUpdated 应该可以解决问题。

如果不是这样,您能分享一下您的 POM 部分吗?

有关 Maven SNAPSHOT 版本的更多信息,请参阅 Maven book :

Maven versions can contain a string literal to signify that a project is currently under active development. If a version contains the string “SNAPSHOT,” then Maven will expand this token to a date and time value converted to UTC (Coordinated Universal Time) when you install or release this component. For example, if your project has a version of “1.0-SNAPSHOT” and you deploy this project’s artifacts to a Maven repository, Maven would expand this version to “1.0-20080207-230803-1” if you were to deploy a release at 11:08 PM on February 7th, 2008 UTC. In other words, when you deploy a snapshot, you are not making a release of a software component; you are releasing a snapshot of a component at a specific time.

因此,通常不需要 lastUpdated 属性。

关于maven-2 - Maven 未下载快照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1328385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com