- 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.
推薦閱讀
- 完全掌握Office 2010高效辦公超級手冊
- 從原始數據到分析報告:Excel數據透視表高效達人養成記
- Excel 2010在會計與財務管理日常工作中的應用
- 用友ERP-U8(8.72版)標準財務模擬實訓
- 游戲引擎原理與實踐·卷1:基礎框架
- 和秋葉一起學:秒懂Excel
- 新編Excel 2010從入門到精通
- Word排版之道
- Excel 2016表格、公式、函數與圖表應用傻瓜書
- Excel 2013超級應用大全(實戰案例版)
- WPS Office辦公應用從入門到精通
- Word綜合應用簡明教程
- Photoshop+Illustrator平面設計案例實戰從入門到精通:視頻自學全彩版
- Excel行政文秘應用之道
- 別讓PPT拖后腿