spring_reference/IX. ‘How-to’ guides/73.1. Customize dependency ...

12 lines
1.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 73.1. 使用Maven自定义依赖版本
如果你使用Maven进行一个直接或间接继承`spring-boot-dependencies`(比如`spring-boot-starter-parent`)的构建,并想覆盖一个特定的第三方依赖,那你可以添加合适的`<properties>`元素。浏览[spring-boot-dependencies](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-dependencies/pom.xml) POM可以获取一个全面的属性列表。例如想要选择一个不同的slf4j版本你可以添加以下内容
```xml
<properties>
<slf4j.version>1.7.5<slf4j.version>
</properties>
```
**注**这只在你的Maven项目继承直接或间接自`spring-boot-dependencies`才有用。如果你使用`<scope>import</scope>`,将`spring-boot-dependencies`添加到自己的`dependencyManagement`片段那你必须自己重新定义artifact而不是覆盖属性。
**注**每个Spring Boot发布都是基于一些特定的第三方依赖集进行设计和测试的覆盖版本可能导致兼容性问题。