How do I prevent Maven 2 from searching remote repositories for specific local depedencies?

后端 未结 4 890
一整个雨季
一整个雨季 2020-12-19 01:46

How do I prevent Maven 2 from searching remote repositories for specific dependencies that are in the local repository only?

4条回答
  •  囚心锁ツ
    2020-12-19 02:11

    Use fixed version numbers in your POM for your remote dependencies or the local versions you want to fetch from the local repository.

    Maven tries to be friendly and fetch the latest and greatest of whatever which has no version number specified.

    For a quick fix to not be waiting for the internet to be downloaded each time you build you can use mvn -o to force an offline build, and then it will not lose time trying to fetch new versions.

    The answer of @crowne is also very good advice, especially setting up your own nexus and making sure all remote repos are configured there so you will never have unpleasant surprises when a repo dissappears some day.

提交回复
热议问题