I want my dependency in dependencyManagement block to inherit a version from spring-boot-parent's dependencyManagement block, but add exclusion to it, so that I don't need to specify that exclusion in each of child modules.
My parent pom inherits from spring-boot-parent:
<artifactId>my-parent</artifactId> <version>1.0.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> <relativePath/> </parent> <dependencyManagement> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>???</version> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> </dependencyManagement> child pom inherits my-parent:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency> </dependencies> I tried several approaches:
When I replace
???with${parent.version}, in child module this version is resolved to bemy-parent's version:1.0.0-SNAPSHOT, which is incorrect.When I replace
???with${parent.parent.version}, maven breaks, as it doesn't support such propertiesI can fix
???to be2.0.1.RELEASEand this will work fine, but if I update the version of spring boot, I have to remember to update the version of this dependency also, which is non-intuitiveI cannot extract
2.0.1.RELEASEas a property inmy-parentand use that property as parent version, as maven does not support that.I could've used property with value
2.0.1.RELEASEinherited fromspring-boot-parentpom, but there is none such property, as far as I can see.
Is there a nice way to achieve what I want?