官术网_书友最值得收藏!

Changing a library's dependencies

Spring Boot includes auto-configuration based on the starter's JAR, which is available on the classpath of the Spring application. Spring Boot POMs has dependencies on the Starters, so you can override dependency versions by setting the appropriate Maven property in your pom.xml like this:

<properties> 
   <spring.version>5.0.0.RELEASE</spring.version> 
</properties> 

There are good reasons to override dependency version sometimes, such as a bug in the given version, or your company policies. Ideally, you should avoid changing a dependency version because it makes your life more complicated as you won't be able to manage the version's transitive dependencies in your application.

If some libraries don't suit your Spring application, you could exclude them from the classpath of the Spring application. Let's see the following example:

<dependency> 
   <groupId>org.springframework.boot</groupId> 
   <artifactId>spring-boot-starter-websocket</artifactId> 
   <exclusions> 
         <exclusion> 
               <groupId>ch.qos.logback</groupId> 
               <artifactId>logback-classic</artifactId> 
         </exclusion> 
   </exclusions> 
</dependency> 
 
<dependency> 
   <groupId>org.slf4j</groupId> 
   <artifactId>slf4j-log4j12</artifactId> 
</dependency> 

As you can see, I have excluded the default logback library from the spring-boot-starter-websocket starter and added the log4j library for application logging.

Let's move to another section about customizing configuration of Spring Boot.

主站蜘蛛池模板: 杭锦旗| 凤翔县| 耿马| 丰宁| 南江县| 南开区| 丁青县| 来宾市| 会昌县| 南宫市| 墨竹工卡县| 台中县| 竹溪县| 青海省| 石城县| 昆明市| 兴和县| 双辽市| 获嘉县| 二连浩特市| 同德县| 台州市| 博罗县| 织金县| 阿合奇县| 新蔡县| 榆中县| 漾濞| 天镇县| 晋中市| 延寿县| 长垣县| 福建省| 修武县| 永泰县| 迁安市| 宜春市| 金平| 康定县| 枣阳市| 磐石市|