- Mastering Spring Boot 2.0
- Dinesh Rajput
- 100字
- 2021-06-25 21:29:14
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.
推薦閱讀
- Word/Excel/PPT 2013辦公應用從入門到精通
- 和秋葉一起學:秒懂Excel
- Salesforce Platform Developer I Certification Guide
- 快·易·通:2天學會PPT幻燈片設計與制作(2016版)
- Excel 必修課:Excel表格制作與數據分析
- Excel 2013財務管理應用全流程實戰指南
- Excel公式、函數、圖表與數據處理應用大全(全新版)
- Excel技術與應用大全
- 和秋葉一起學Excel(第2版)
- PowerPoint!讓教學更精彩:PPT課件高效制作(全彩)
- 快速編碼:高效使用MicrosoftVisualStudio
- Word Excel PPT 2013:辦公應用從入門到精通
- Windows 10從入門到精通
- Office 2010高效辦公應用技巧(雙色精華版)
- 電腦急救完全DIY