I would like to use a Spring Boot library:
<artifactId>my-project</artifactId> <parent> <artifactId>my-project-parent</artifactId> ... </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> </dependencies> I've got other, similar projects and I'd like to manage the version of Spring in one place:
<artifactId>my-project-parent</artifactId> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.4.0.RELEASE</version> </parent> However, I don't want Spring's logging libraries. I've got my own.
<artifactId>my-project</artifactId> <parent> <artifactId>my-project-parent</artifactId> ... </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> </dependencies> That works.
But I don't want to have to repeat the exclusion every time I use the dependency:
<artifactId>my-project</artifactId> <parent> <artifactId>my-project-parent</artifactId> ... </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> </dependencies> <artifactId>my-project-parent</artifactId> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.4.0.RELEASE</version> </parent> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </dependencyManagement> That doesn't work.
Project build error: 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-data-jpa:jar is missing. Of course, I can specify just hard-code the same version as is used in spring-boot-dependencies:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <version>1.4.0.RELEASE</version> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> But now I have to manage two versions (which happen be the same in this case).
Is there a way for me to inherit/import dependencies and manage exclusions without having to repeat versioning information?