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

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.

主站蜘蛛池模板: 朝阳县| 井陉县| 昌都县| 红安县| 洛隆县| 莲花县| 昭苏县| 潍坊市| 永宁县| 巴马| 普宁市| 柳林县| 奉贤区| 洛川县| 九江市| 西安市| 阿拉尔市| 石阡县| 红桥区| 甘肃省| 乐都县| 元朗区| 新民市| 关岭| 青龙| 大余县| 繁峙县| 鄂托克旗| 山西省| 福鼎市| 湛江市| 云龙县| 通榆县| 鲁山县| 望江县| 丹阳市| 鄄城县| 宁晋县| 静安区| 隆安县| 禄丰县|