@SpringBootApplication注解到底做了什么,你真的了解吗?
发布日期:2021-06-30 12:24:40
浏览次数:2
分类:技术文章
本文共 1558 字,大约阅读时间需要 5 分钟。
@SpringBootApplication
@Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)@Documented@Inherited@SpringBootConfiguration@EnableAutoConfiguration@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })public @interface SpringBootApplication {
@Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)@Documented@Inherited@AutoConfigurationPackage@Import(AutoConfigurationImportSelector.class)public @interface EnableAutoConfiguration { String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration"; /** * Exclude specific auto-configuration classes such that they will never be applied. * @return the classes to exclude */ Class [] exclude() default { }; /** * Exclude specific auto-configuration class names such that they will never be * applied. * @return the class names to exclude * @since 1.3.0 */ String[] excludeName() default { };}
注意到AutoConfigurationImportSelector类
返回AutoConfigurationImportSelector.AutoConfigurationEntry基础上, AnnotationMetadata import的@Configuration类。
-
autoConfigurationMetadata - 自动配置的元数据
-
annotationMetadata - 配置类的注释元数据
返回:应导入自动配置 -
获得配置
返回应该被视为自动配置类名。 默认情况下,此方法将使用加载候选人SpringFactoriesLoader与getSpringFactoriesLoaderFactoryClass() -
元数据 - 源元数据
-
属性-将annotation attributes
返回:候选配置列表 看下其中的断言中指定的
META-INF/spring.factories
为我们实现了很多自动装配
我们随便看下这个类- 内嵌的 tomcat
- 其实就是开启 springMVC,这只是 sb 批量自动装配的一个组件
ServletWebServerFactoryAutoConfiguration
自动装配 - 启动一个内嵌的 tomcat转载地址:https://javaedge.blog.csdn.net/article/details/105776811 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年05月04日 10时18分46秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【深度学习笔记】残差
2019-04-30
【python学习笔记】读取指定文件夹中的图片,结合边缘保留滤波EPF
2019-04-30
【工具和环境】Linux下安装pycharm
2019-04-30
【Accumulation】The definition of SISR
2019-04-30
【工具与环境】Windows下安装Sublime Text 3
2019-04-30
【工具与环境】Excel中批量插入行
2019-04-30
【个人实验注意事项】
2019-04-30
【学习笔记】对vanilla的一些个人理解
2019-04-30
【解决错误】The size of tensor a (8) must match the size of tensor b (64) at non-singleton dimension 1
2019-04-30
word文档中实现目录索引中标题加粗,前导符和页码不加粗
2019-04-30
“学硕” VS “专硕”
2019-04-30
【NLP学习笔记】知识图谱阅读笔记及其心得
2019-04-30
【工具使用】新版CSDN-markdown编辑器使用指南
2019-04-30
《知识图谱》阅读笔记(六)
2019-04-30