本文介绍了有没有办法让Maven自动下载快照版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个依赖于另一个项目的快照版本的项目。依赖关系是:

So I have a project that depends on a snapshot version of another project. The dependency is:

<dependency>
  <groupId>org.oop</groupId>
  <artifactId>oop</artifactId>
  <version>0.9.9-SNAPSHOT</version>
</dependency>

对于oop项目,我确实做了'mvn clean deploy',所以快照版应该是在maven中央存储库的某个地方。但是当我进行mvn clean安装时,上面的快照依赖项无法解决,我得到了这个:

For the oop project, I did do a 'mvn clean deploy', so the snapshot version should be somewhere in the maven central repository. But when I do a mvn clean install, the snapshot dependency above cannot be resolved and I get this:

缺少:

1)org.oop:oop:jar:0.9.9-SNAPSHOT

1) org.oop:oop:jar:0.9.9-SNAPSHOT

尝试从项目网站手动下载文件。

Try downloading the file manually from the project website.

然后,使用以下命令安装它:
mvn install:install-file -DgroupId = org.oop -DartifactId = oop -Dversion = 0.9.9-SNAPSHOT -Dpackaging = jar -Dfile = / path / to / file

Then, install it using the command: mvn install:install-file -DgroupId=org.oop -DartifactId=oop -Dversion=0.9.9-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

或者,如果您拥有自己的存储库,则可以在那里部署文件:
mvn deploy:deploy-file -DgroupId = org.oop -DartifactId = oop -Dversion = 0.9.9-SNAPSHOT -Dpackaging = jar -Dfile = / path / to / file -Durl = [url] -DrepositoryId = [id]

Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.oop -DartifactId=oop -Dversion=0.9.9-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

有没有办法让maven自动下载快照?我必须在这里遗漏一些东西。

Is there a way to make maven download the snapshot automatically? I must be missing something here.

EDIT1 :在我的settings.xml上,我有:

On my settings.xml I have:

   <server>
      <id>sonatype-nexus-snapshots</id>
      <username>XXXXXX</username>
      <password>XXXXXX</password>
    </server>

    <server>
      <id>sonatype-nexus-staging</id>
      <username>XXXXXX</username>
      <password>XXXXXX</password>
    </server>

EDIT2:

推荐答案

只需将其添加到〜/ .m2 / settings.xml:

Just add this to your ~/.m2/settings.xml:

<profiles>
  <profile>
     <id>allow-snapshots</id>
        <activation><activeByDefault>true</activeByDefault></activation>
     <repositories>
       <repository>
         <id>snapshots-repo</id>
         <url>https://oss.sonatype.org/content/repositories/snapshots</url>
         <releases><enabled>false</enabled></releases>
         <snapshots><enabled>true</enabled></snapshots>
       </repository>
     </repositories>
   </profile>
</profiles>

这篇关于有没有办法让Maven自动下载快照版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 05:31