springboot2.0深度实践

核心特性

Spring Boot 三大特性

  1. 组件自动装配:Web Mvc、Web Flux、JDBC
  2. 嵌入式WEB容器:Tomcat、Jetty 以及 Undertow
  3. 生产准备特性:指标、健康检查、外部化配置

Spring Boot Bean 源码解读

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class SpringApplicationBootstrap {
public static void main(String[] args) {
// 在 run 方法中可以填入带有 @SpringBootApplication 的注解的类
// SpringApplication.run(ApplicationTest.class, args);
// 引导类的配置
Set<String> sources = new HashSet<>();
sources.add(ApplicationTest.class.getName());
SpringApplication springApplication = new SpringApplication();
springApplication.setSources(sources);
ConfigurableApplicationContext context = springApplication.run(args);
System.out.println("Bean "+context.getBean(ApplicationTest.class));
}
@SpringBootApplication
public static class ApplicationTest{

}
}

Spring 可以通断出当前应用的类型,主要是在 SpringApplication 中的 org.springframework.boot.SpringApplication#setApplicationContextClass 方法中

作者

Bruce Liu

发布于

2019-03-29

更新于

2022-11-12

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.