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

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.

主站蜘蛛池模板: 吉安县| 兴宁市| 丹江口市| 土默特右旗| 乌鲁木齐市| 金寨县| 岑巩县| 泉州市| 赫章县| 泰兴市| 辉县市| 财经| 乌兰浩特市| 得荣县| 武城县| 淳安县| 崇仁县| 株洲市| 安陆市| 邵阳市| 柳州市| 舟山市| 龙门县| 绥宁县| 池州市| 望谟县| 鹤峰县| 桐梓县| 浦北县| 新河县| 崇明县| 芮城县| 砚山县| 江陵县| 巴彦淖尔市| 得荣县| 分宜县| 锡林郭勒盟| 延庆县| 建水县| 明溪县|