How to maintain version for maven dependency?
I have below spring boot module and all are devcelop in maven.
- common
- service
- registration
- report
- transaction
All are independent project. Only common module is having some common features and its included as a jar in other module.
Now all the module they are using maven dependency and spring boot also they are used few common jar files. So I need to maintain all jar version in all module.
So is there any work around for maintain version in some common place???
for example below dependency I have used in all module
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.3.1</version> </dependency>
I have to maintain this in all pom file. If try to upgrade version then I need to do this change in all file.
But If we get this from single file then I just need to do this in sigle place and reflect in all place.
Please give some idea how to do that?
You can use <dependencyManagement>
to retain the same version of the artifact in all child poms. This way you mention a version only in one place.
// parent pom:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.3.1</version> </dependency> </dependencies> </dependencyManagement>
// child pom:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> </dependencies>