how to prevent maven from checking foreign repositories?

拜拜、爱过 提交于 2019-12-03 07:37:00

If the remote repositories that you are using are release repositories and do actually not contain any SNAPSHOT, they you can disable SNAPSHOT for them and Maven won't check them for SNAPSHOT updates. For example:

<repositories>
  <repository>
    <id>java.net</id>
    <url>http://download.java.net/maven/2</url>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
  ...
</repositories> 
Vivien Barousse

You can try with passing the "-o" option to Maven. -o activates the "Offline mode", in which Maven doesn't query remote repositories to check for updates or new artifacts.

I don't think that you can specify this on a per-dependency basis.

By default maven checks dependencies in your local repository first, then on external repositories. The only case which will make maven check external repositories, is the use of snapshots.

If you use snapshots, you can use the <updatePolicy> markup to change when your external repository will be checked.

If you wan to work in offline mode you can either set a temporary offline option on your mvn command with the "-o" option, or you can set it up in your "~/.m2/settings.xml" with <offline>true</offline>.


Before you do so, remember to use the dependecy:go-offline mojo to download your dependency once before you really activate the offline mode.


Resources :

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