4

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?

3
  • 1
    Use two variables for spring-boot-dependencies version and spring-boot-starter-data-pa version, initially assign the second with the first Commented Sep 5, 2016 at 14:40
  • 1
    I know. But it just seems weird that I have to do that. Surely it already knows the version!? (via the parent) It seems contrary to the rest over Maven behaviour. I.e. Properties are inherited and potentially overridden. Commented Sep 6, 2016 at 20:10
  • 1
    dependencyManagement tag is built to hold all GAV data ... what you propose would be a nice to have feature Commented Sep 7, 2016 at 7:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.