Defining Repository in Maven

白昼怎懂夜的黑 提交于 2019-12-11 08:34:28

问题


I have just started with couple of projects in maven , keen to know what is the best way to define repository ?

What I understood so far is the following two ways : 1. Local 2. Remote When we are using local repository we are refering to our installation or it will check the depency first in a local directory(cache of remote)

While remote repository set up a third party to download their artifacts.(e.g somewhere file://someurl or http://someurl)

Please correct me if I am wrong , and I want to know what is the best way to define repositories keeping in mind if some one is using project on a low bandwidth connection the performance should not hamper .


回答1:


The best way is to keep the default behavior: a local repository located in <USER_HOME>/.m2/repository.

The first(s) mvn command you will run will be slow because this repository need to be populated by a lot of libraries (maven plugins and libraries and frameworks in your dependencies).

This local repository is where your artifacts will be installed when you run mvn install.

If you need to share artifacts with colleagues, either you :

  • do it through SCM (i.e. your colleagues will have to checkout your code and run mvn install so that your libraries will be available in their local repository)
  • do it through a repository manager (artifactory or nexus) (then run mvn deploy with proper configuration in your settings.xml to make your artifacts available for your colleagues in a binary form via the repository manager).

I suggest you to first getting familiar with maven before installing a repository manager.




回答2:


The best thing is to install a repository manager as remote repository and configure the settings.xml appropriately. The local repository is automatically filled with the dependencies as they are being used.



来源:https://stackoverflow.com/questions/15410454/defining-repository-in-maven

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