How to download SNAPSHOT version from maven SNAPSHOT repository?

不羁的心 提交于 2019-11-28 18:14:40

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>

For the sake of completeness, I would like to add that it is also possible by modifying the pom.xml of a project, simply add

    <repository>
      <id>oss.sonatype.org-snapshot</id>
      <url>http://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

to your list of repositories.

In my opinion, this is a better solution than modifying ~/.m2/settings.xml. The pom.xml file will also be available for other project participants through Git and allow them to download the snapshots as well.

Source: this answer

You can enable snapshots in repository config (~/.m2/settings.xml):

<settings>
    <profiles>
        <profile>
          <repositories>
            <repository>
              <snapshots>                  <<<<<<<<<<<
                <enabled>true</enabled>    << ADD THIS
              </snapshots>                 <<<<<<<<<<<
  . . .
</settings>

See maven.apache.org/settings.html#Repositories for more properties.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!