How to share project dependencies among multiple projects in Maven?
I have the below project structure
Main Project
--Sub Project 1
- child 1
* pom-child1
- child 2
* pom-child2
* pom-sub-project1
--Sub Project 2
* pom-sub-project2
* main project pom
I had defined few project dependencies in main project pom and referred it in child and sub project poms. But I am finding issues if the pom is not a direct child of the main project pom. Is there a way to resolve it?
Example, Main Project pom
<packaging>pom</packaging>
<version>dev</version>
<name>parent-project</name>
..
<properties><spring-version>3.1.0.RELEASE</spring-version></properties>
child POM
<parent>
<groupId>com.test.pkg</groupId>
<artifactId>test-proj</artifactId>
<version>${project.version}</version>
</parent>
The ${project.version} isn't resolved if it is not a direct child of a parent pom due to which none of the project dependencies are resolved.
Also, I read about properties-maven-plugin which is used to read properties from external properties file. Can this be used for reading dependency version or is there any other plugin/approach that could be used in this case?
You cannot use
${project.version}
to define your parents version, because the child by default inherits the parents version.
Set the parents version with the valid value and not with a property.
If you do so, it should work and you do not have to specify the childs version, as it will be inherited from the parent.
链接地址: http://www.djcxy.com/p/29706.html上一篇: 剪切到绘制路径