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

Replacing generated beans

You can also customize Spring Boot auto-configuration by defining certain beans yourself in your Spring application, so Spring Boot won't use default configuration for those beans.

Normally, beans you declare explicitly disable any auto-created ones. Let's see the following example:

@Bean 
public DataSource dataSource() { 
   return new EmbeddedDatabaseBuilder(). 
         setName("AccountDB").build(); 
} 

In the preceding code, we have explicitly defined a DataSource bean; your DataSource bean configuration stops Spring Boot from creating a default DataSource. Bean names are often not important. It works with XML-based configuration, annotation, and/or Java-based configuration.

Let's see another way of customizing Spring Boot autoconfiguration.

主站蜘蛛池模板: 涞水县| 六枝特区| 如皋市| 巴林右旗| 敦煌市| 抚州市| 紫云| 周宁县| 八宿县| 股票| 西青区| 绥芬河市| 瑞丽市| 西乡县| 龙江县| 蓬莱市| 镇康县| 临西县| 门源| 湾仔区| 水城县| 双流县| 京山县| 明光市| 象山县| 灯塔市| 昔阳县| 湟源县| 武义县| 藁城市| 罗定市| 星子县| 静乐县| 临湘市| 神池县| 荣昌县| 乐昌市| 鄂温| 双城市| 龙州县| 旅游|