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

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.

主站蜘蛛池模板: 特克斯县| 乐安县| 仙游县| 静海县| 青浦区| 巴南区| 白沙| 搜索| 沽源县| 伊春市| 延寿县| 开封市| 开封市| 汪清县| 扬州市| 延边| 阜康市| 于田县| 平原县| 东平县| 增城市| 万年县| 盖州市| 固安县| 三亚市| 东光县| 临桂县| 科技| 绥棱县| 道真| 新干县| 大厂| 枣阳市| 景谷| 嵊泗县| 道孚县| 泊头市| 武陟县| 会泽县| 白山市| 丹棱县|