博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
《SpringBoot揭秘 快速构建微服务体系》读后感(二)
阅读量:4625 次
发布时间:2019-06-09

本文共 1141 字,大约阅读时间需要 3 分钟。

最简单的springBoot应用

package com.louis.test;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class Run {    public static void main(String[] args) {        SpringApplication.run(Run.class, args);    }}

1、@SpringBootApplication背后的秘密

@SpringBootApplication是一个“三体”结构,实际上是一个复合Annotation:

 

 但主要的是这三个Annotation:

@Configuration

@EnableAutoConfiguration

@ComponentScan

所以上面的代码与下面的代码是等价的

package com.louis.test;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.context.annotation.ComponentScan;import org.springframework.context.annotation.Configuration;@Configuration@EnableAutoConfiguration@ComponentScanpublic class Run {    public static void main(String[] args) {        SpringApplication.run(Run.class, args);    }}

@Configuration

DemoApplication其实就是一个标准的Standalone类型的java程序的main函数启动类,没有什么特殊的

而@Configuration标注的DemoConfiguration定义其实也是一个普通的JavaConfig形式的IOC容器配置类

@EnableAutoConfiguration

 

 

 

 

@ComponentScan

 

转载于:https://www.cnblogs.com/Michael2397/p/7866824.html

你可能感兴趣的文章
android 开发工具(转)
查看>>
python中的uuid4
查看>>
CSS 必知的7个知识点
查看>>
asp.net mvc 生成条形码
查看>>
单调队列
查看>>
Attribute value is quoted with " which must be escaped when used within the value 问题解决
查看>>
作业01
查看>>
web学习记录-JS-12
查看>>
ubuntu安装软件包apt-get和dpkg方法
查看>>
工作中vue项目前后端分离,调用后端本地接口出现跨域问题的完美解决
查看>>
BZOJ3894: 文理分科
查看>>
动态生成元素动作绑定,jquery 1.9如何实现
查看>>
C语言经典算法100例-032~35
查看>>
[14]APUE:API for Mysql
查看>>
递归列出文件树
查看>>
LeetCode53最大子序和
查看>>
201504进度
查看>>
SDUT_2012省赛选拔赛3
查看>>
MySQL的安装与卸载图解
查看>>
Html5游戏从0开始
查看>>