how to prevent maven from checking foreign repositories?

前端 未结 3 1317
清酒与你
清酒与你 2021-02-09 17:12

When I build using maven I see it checking all sort of foreign repositories for artifacts which only my local build should produce. How can I tell it that the com.myorg group c

相关标签:
3条回答
  • 2021-02-09 17:21

    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> 
    
    0 讨论(0)
  • 2021-02-09 17:34

    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.

    0 讨论(0)
  • 2021-02-09 17:38

    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 :

    • Maven - Repositories
    • Maven - simple settings values
    • Maven - dependecy:go-offline
    0 讨论(0)
提交回复
热议问题