Maven 未下载快照

发布于 2024-08-02 15:28:59 字数 2548 浏览 8 评论 0原文

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

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

[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>

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

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

I am trying to set up Maven with a Repository located in our local Network and I already have set up a Repository for snapshots and one for Releases (both apache archiva).

Downloading the packages from the release repository works fine. However I keep getting errors, when I try to load SNAPSHOT versions from the snapshot repository, when I try to download a SNAPSHOT I deployed myself:

[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),

The package is available in the snapshots-repo, network is up, login works fine.

My pom.xml looks like this:

 [...]
<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>
 [...]

I checked also the maven-metadata.xml that was downloaded from the snapshot-repo:

<?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>

It shows the correct date and timestamp (a package containing this timestamp is present in the repo).

Am I missing something concerning the repository setup or the SNAPSHOT concept? Did anybody had the same problem? Or does somebody know about some detailed documentation about SNAPSHOTs and Repositories?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

謸气贵蔟 2024-08-09 15:28:59

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

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

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

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

有关 Maven SNAPSHOT 版本的更多信息,请参阅 Maven 书籍

Maven 版本可以包含字符串文字来表示项目当前正在积极开发中。如果版本包含字符串“SNAPSHOT”,那么当您安装或发布此组件时,Maven 会将此标记扩展为转换为 UTC(协调世界时)的日期和时间值。例如,如果您的项目的版本为“1.0-SNAPSHOT”,并且您将该项目的工件部署到 Maven 存储库,则如果您要在 11 部署版本,Maven 会将此版本扩展为“1.0-20080207-230803-1” UTC 时间 2008 年 2 月 7 日晚上 8 点。换句话说,当您部署快照时,您并不是在发布软件组件;而是在发布软件组件。您正在特定时间发布组件的快照。

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

What does the dependency declaration for my-app look like? I'd expect it to look like this:

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

From the error, it looks like it has been generated by an archetype and added the lastUpdated type. If that is the case removing lastUpdated should resolve the issue.

If that's not the case, can you share the section of your POM please?

For more information on Maven SNAPSHOT versions, see the 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.

The lastUpdated property is therefore not typically needed.

小耗子 2024-08-09 15:28:59

使用 -e 标志运行 mvn 以获取更详细的错误消息。

Run the mvn with the -e flag for more detailed error messages.

痴意少年 2024-08-09 15:28:59

你的settings.xml 文件怎么样?

如果你的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>

那么setting.xml应该有类似的内容:

<server>
    <id>my-snapshots</id>
    <username>user</username>
    <password>pass</password>
    <privateKey>${user.home}/.ssh/id_dsa</privateKey>
    <passphrase>some_passphrase</passphrase>
    <filePermissions>664</filePermissions>
    <directoryPermissions>775</directoryPermissions>
    <configuration></configuration>
  </server>

1)存储库用户名和密码必须如上

2)settings和pom中的id标签必须相同:

<id>my-snapshots</id>

What about your settings.xml file?

if your pom xml has the following:

<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>

then the setting.xml should have something like:

<server>
    <id>my-snapshots</id>
    <username>user</username>
    <password>pass</password>
    <privateKey>${user.home}/.ssh/id_dsa</privateKey>
    <passphrase>some_passphrase</passphrase>
    <filePermissions>664</filePermissions>
    <directoryPermissions>775</directoryPermissions>
    <configuration></configuration>
  </server>

1) The repository username and password must be as above

2) The id tag in both settings and pom must be the same:

<id>my-snapshots</id>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文