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

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.

主站蜘蛛池模板: 马尔康县| 扶沟县| 北宁市| 安远县| 安阳市| 通城县| 天全县| 都江堰市| 兰溪市| 洪洞县| 山丹县| 南部县| 威远县| 盘锦市| 泸溪县| 霍州市| 连云港市| 鄱阳县| 西乌珠穆沁旗| 无锡市| 通道| 浙江省| 高唐县| 马尔康县| 沧州市| 宝应县| 云安县| 昌宁县| 五家渠市| 夏邑县| 雅安市| 安多县| 乌苏市| 家居| 运城市| 淳化县| 东城区| 鸡泽县| 鄄城县| 勃利县| 嫩江县|