zoukankan      html  css  js  c++  java
  • SpringBoot自动配置原理

    先你会注意到,SpringBoot应用启动类都会有@SpringBootApplication

    通过查看@SpringBootApplication源码,关键就在于@SpringBootConfiguration、@EnableAutoConfiguration,@ComponentScan这三个 

    @SpringBootConfiguration
    根据Spring文档,只是Spring标准@Configuration批注的替代方法。 两者之间的唯一区别是@SpringBootConfiguration允许自动找到配置。
    通过源码可以看到@Configuration注解,这个注解的作用就是声明当前类是一个配置类,Spring就会自动扫描到添加了@Configuration的类,并且读取其中的配置信息。

    @EnableAutoConfiguration

    通过源码发现,关键使用@Import引入了AutoConfigurationImportSelector类,该类使用selectImports()方法扫描具有META-INF/spring.factories文件的jar包。
    拓展:spring.factories文件是Key=Value形式,多个Value时使用逗号隔开。

    @ComponentScan
    主要作用就是扫描@SpringBootApplication注解的Application类所在的包下所有的@component注解(或拓展了@component的注解)标记的bean,并注册到spring容器中。
    ————————————————
    原文链接:https://blog.csdn.net/qq_36433289/article/details/115022789

  • 相关阅读:
    joins and includes
    学习库
    HTML5 画图--文字
    http://qiye.qianzhan.com/ 企业查询宝
    js 获取input选择的图片的信息
    input:file属性
    CSS 箭头
    颜色
    CSS 点击图片替换样式
    图片转base64
  • 原文地址:https://www.cnblogs.com/huozhonghun/p/14560188.html
Copyright © 2011-2022 走看看