我想使用Spring Boot库:
<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>
我还有其他类似的项目,我想在一个地方管理Spring的版本:
<artifactId>my-project-parent</artifactId>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
但是,我不想要Spring的日志库。我有自己的。
<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>
有效。
但是我不希望每次使用依赖项时都要重复排除:
<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>
那不起作用。
Project build error: 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-data-jpa:jar is missing.
当然,我可以指定硬编码与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>
但现在我必须管理两个版本(在这种情况下会发生相同的情况)。
我有没有办法继承/导入依赖关系并管理排除,而不必重复版本信息?