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

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.

主站蜘蛛池模板: 玉山县| 乌兰察布市| SHOW| 靖远县| 合阳县| 和田县| 岚皋县| 理塘县| 浦城县| 崇礼县| 盐池县| 平远县| 齐河县| 广灵县| 宾阳县| 鄱阳县| 杂多县| 翁源县| 营口市| 陇南市| 西乌珠穆沁旗| 平顺县| 诸城市| 富川| 丰顺县| 青川县| 义马市| 潞西市| 邯郸县| 铜陵市| 汨罗市| 安多县| 呼图壁县| 新余市| 马山县| 菏泽市| 姜堰市| 曲阜市| 扎兰屯市| 武强县| 时尚|