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

  • Mastering Spring Boot 2.0
  • Dinesh Rajput
  • 125字
  • 2021-06-25 21:29:15

Disabling specific auto-configuration classes

At any point in time, if you don't want to use some of the specific auto-configuration classes or if they don't suit your needs, you can disable those auto-configuration classes. For this, you can use the exclude attribute of the @EnableAutoConfiguration annotation. Let's see the following example:

@EnableAutoConfiguration(exclude=DataSourceAutoConfiguration.class) 
public class ApplicationConfiguration { 
   ... 
} 

As per the code snippet, we have used the @EnableAutoConfiguration annotation with the exclude attribute. The DataSourceAutoConfiguration class will be excluded from the auto-configuration. Similarly, we can define a list of auto-configuration classes that need to be excluded.

You can define exclusions both at the annotation level and by using the property.

Let's move to another point of customizing auto-configuration in the Spring Boot application.

主站蜘蛛池模板: 龙里县| 远安县| 嵩明县| 嘉鱼县| 汝城县| 渝北区| 青川县| 卢龙县| 万荣县| 正定县| 新津县| 万源市| 横峰县| 左云县| 新兴县| 滕州市| 于田县| 桐庐县| 定兴县| 孝昌县| 诏安县| 呼图壁县| 巴林左旗| 密云县| 金沙县| 遂川县| 澳门| 罗江县| 雅江县| 哈密市| 平邑县| 琼结县| 和田县| 旌德县| 兴义市| 西吉县| 北票市| 依安县| 拜泉县| 黄浦区| 潜山县|