maven 3 - How can I overwrite parent version number in parent module from sub module -
i building spring application consists of multiple spring projects micro-services. want put these spring projects parent module , convert multi-module maven project. have met problem each sub-module needs have parent reference spring-cloud-starter-parent, natually, moving parent module. problem happened, each submodule using different version of spring-cloud-starter-parent. let's see below.
part of pom parent module:
<groupid>com.demo</groupid> <artifactid>spring-cloud-demo</artifactid> <version>2.0</version> <packaging>pom</packaging> <name>spring cloud demo</name> <parent> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-parent</artifactid> <version>angel.sr3</version> </parent>
and in sub-module, part of pom is:
<parent> <groupid>com.demo</groupid> <artifactid>spring-cloud-demo</artifactid> <version>2.0</version> <relativepath>../pom.xml</relativepath> </parent>
i though working, spring-cloud-starter-parent introduced in parent module, available in sub-module. met problem, child sub-module needs have different spring-cloud-starter-parent version, example, 1.0.0-snapbuild.
in case, how can still use multi-module maven project structure? how can use different parent version in sub-module? or have separate 2 different projects?
thanks.
you should able override parent dependency in sub module pom point @ specific dependencies need.
dependency mediation - determines version of dependency used when multiple versions of artifact encountered. currently, maven 2.0 supports using "nearest definition" means use version of closest dependency project in tree of dependencies. can guarantee version declaring explicitly in project's pom. note if 2 dependency versions @ same depth in dependency tree, until maven 2.0.8 not defined 1 win, since maven 2.0.9 it's order in declaration counts: first declaration wins.
"nearest definition" means version used closest 1 project in tree of dependencies, eg. if dependencies a, b, , c defined -> b -> c -> d 2.0 , -> e -> d 1.0, d 1.0 used when building because path d through e shorter. explicitly add dependency d 2.0 in force use of d 2.0
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
Comments
Post a Comment