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

  • Mastering Spring Boot 2.0
  • Dinesh Rajput
  • 186字
  • 2021-06-25 21:29:14

Understanding auto-configuration

Spring Boot auto-configuration provides automatic configuration to your Spring application based on the modules and associated library dependencies of those modules that you have added. For instance, if you have added the embedded in-memory database H2 in your classpath, you are not required to manually configure any bean related to the database such as DataSource, JdbcTemplate, and so on. Spring Boot provides your H2 database with auto-configuration after adding dependency on the H2 database in your application's classpath.

Spring Boot provides the magic of autoconfiguration by extensive use of pre-written @Configuration classes for each module of Spring Framework. But these auto-configurations are activated based on:

  • The contents of the classpath of your Spring application
  • Properties you have set in the application
  • Beans already defined in your application

The @Profile annotation of Spring Framework is an example of conditional configuration. Spring Boot takes this idea to the next level and provides a layer of auto-configuration on top of the traditional Spring Framework. That is why Spring Boot is not a separate framework by heart; it is Spring Framework.

@Profile is a special case of @Conditional.

主站蜘蛛池模板: 通榆县| 曲沃县| 民和| 得荣县| 潼关县| 墨玉县| 临颍县| 尉犁县| 化德县| 南漳县| 卓尼县| 常山县| 区。| 建湖县| 云安县| 论坛| 砚山县| 阿勒泰市| 新泰市| 称多县| 沙湾县| 宽城| 莆田市| 汝南县| 彰化县| 通化县| 启东市| 都昌县| 本溪| 日土县| 简阳市| 台前县| 茌平县| 舟山市| 刚察县| 自贡市| 南召县| 横山县| 临澧县| 辽宁省| 彩票|