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

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.

主站蜘蛛池模板: 长汀县| 格尔木市| 章丘市| 蕉岭县| 印江| 宁陵县| 图木舒克市| 博湖县| 逊克县| 增城市| 甘德县| 乌拉特后旗| 晋宁县| 酉阳| 马鞍山市| 汉川市| 忻城县| 京山县| 江陵县| 淅川县| 竹山县| 洛宁县| 保靖县| 镇平县| 淮南市| 芜湖市| 葫芦岛市| 太仓市| 淳化县| 蕉岭县| 同江市| 冕宁县| 博湖县| 乐安县| 玉屏| 原阳县| 肃宁县| 雅安市| 新沂市| 扶风县| 舞钢市|