Centralize POM Dependencies for my desktop

*爱你&永不变心* 提交于 2019-12-11 16:03:41

问题


  1. I have multiple eclipse workspaces with maven projects.
  2. Some projects use the same dependencies in pom.xml but different versions.
  3. Can I have a single pom.xml on my computer, each workspace/project pom.xml will point to this main pom.xml
  4. So that i can control the version of the dependencies in the main pom.xml rather than each pom.xml in each workspace/project.

Any suggestions how to set this up will be helpful. Thanks again for checking this.


回答1:


The pattern that you describe is called "Bill of Material".

You create a new maven project (the bill of material) that only consists of a pom with dependency management block. Here you declare all your dependencies and their versions. The packaging should be set to pom.

This bill of material (bom) project is now used as parent of all other projects. When using a dependency, only group id and artifact id is specified, the version tag is ommited. In that way, the version will be taken from the bom and you have one central place to manage the versions of the dependencies.

More details with examples are here (in the lower part of the page) or here.



来源:https://stackoverflow.com/questions/49559662/centralize-pom-dependencies-for-my-desktop

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