- 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.
推薦閱讀
- 新手易學:電腦辦公
- The Art of CRM
- Excel財務會計應用
- Excel 2019公式、函數應用大全
- Salesforce Platform Developer I Certification Guide
- 和秋葉一起學:秒懂Word(全彩版)
- 基于BIM的Revit機電管線設計案例教程
- 左手Excel右手Tableau數據分析可視化實戰案例視頻精講
- Office辦公應用技巧
- Office 2021辦公應用實戰從入門到精通
- PPT職場利器:PPT商務應用案例大全
- Excel VBA案例實戰從入門到精通(視頻自學版)
- Word/Excel/PowerPoint 2007三合一辦公應用實戰從入門到精通
- 圖表之美:打造優秀的Excel圖表
- Excel 2013從新手到高手