-
課堂總結
主要內(nèi)容
Spring Boot 核心特性
Spring Boot 功能應用
Spring Boot 運維管理
降龍十八掌 第十八式
查看全部 -
運維管理
Spring Boot Actuator
端點:各類Web和JMX Endpoints
健康檢查:Health、HealthIndicator
指標:內(nèi)建Metrics、自定義Metrics
Spring Boot Actuator
依賴
<dependency>
? ? ?????????<groupId>org.springframework.boot</groupId>
? ? ? ? ? ? <artifactId>spring-boot-starter-actuator</artifactId>
? ? ? ? </dependency>
端點(Endpoints)
Web Endpoints
JMX Endpoints
健康檢查(Health Checks)
Health
HealthIndicator
指標(Metrics)
內(nèi)建Metrics
Web Endpoint:/actuator/metrics
自定義Metrics
查看全部 -
功能擴展
Spring Boot 應用
SpringApplication:失敗分析、應用特性、事件監(jiān)聽等
Spring Boot配置:外部化配置、Profile、配置屬性
Spring Boot Starter:Starter開發(fā)、最佳實踐
SpringApplication
失敗分析
FailureAnalysisReporter
應用特性
SpringApplication Fluent API
Spring Boot配置
外部化配置
ConfigurationProperty
@Profile
配置屬性
PropertySources
Spring Boot Starter
查看全部 -
數(shù)據(jù)相關
關系型數(shù)據(jù)
JDBC:數(shù)據(jù)源、JdbcTemplate、自動裝配
JPA:實體映射關系、實體操作、自動裝配
事務:Spring事務抽象、JDBC事務處理、自動裝配
JDBC
依賴
<dependency>
? ? ? ? ? ? ? ? <groupId>org.springframework.boot</groupId>
? ? ? ? ? ? ? ? <artifactId>spring-boot-starter-jdbc</artifactId>
? ? ? ? </dependency>
? ? 數(shù)據(jù)源
? ? ? ? javax.sql.DataSource
? ? JdbcTemplate
? ? 自動裝配
? ? ? ? DataSourceAutoConfiguration
? ? JPA
? ? 依賴
? ? <dependency>
? ? ? ? <groupId>org.springframework.boot</groupId>
? ? ? ? <artifactId>spring-boot-starter-data-jpa</artifactId>
? ? </dependency>
實體映射關系
@javax.persistence.OneToOne
@javax.persistence.OneToMany
@javax.persistence.ManyToOne
@javax.persistence.ManyToMany
...
實體操作
javax.persistence.EntityManager
自動裝配
HibernateJpaAutoConfiguration
事務(Transaction)
依賴
<dependency>
? ? <groupId>org.springframework</groupId>
? ? <artifactId>spring-tx</artifactId>
</dependency>
Spring事務抽象
platfromTransactionManager
JDBC事務處理
DataSourceTransactionManager
自動裝配
TransactionAutoConfiguration
查看全部 -
Web Server 應用
? ? 切換 Web Server
? ? 自定義 Servlet Web Server
自定義Reactive Web Server
Web Server應用
切換Web Server
切換其他Servlet容器
Tomcat->Jetty
<dependency>
? ? <groupId>org.springframework.boot</groupId>
? ? <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
替換Servlet容器
WebFlux
注釋調(diào)傳統(tǒng)的web容器
<dependency>
? ? <groupId>org.springframework.boot</groupId>
? ? <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
//@ServletComponentScan(basePackages = "com.imooc.diveinspringboot.web.servlet")
Netty started on port(s):8080
自定義Servlet Web Server
WebServerFactoryCustomizer
自定義Reactive Web Server
ReactiveWebServerFactoryCustomizer
查看全部 -
Web應用
Spring Web Flux 應用
Reactor基礎:Java Lambda、Mono、Flux
Web Flux核心:Web MVC 注解、函數(shù)式聲明、異步非阻塞
使用場景:Web Flux的優(yōu)勢和限制
查看全部 -
Web應用
Spring Web MVC應用
Web MVC視圖:模版引擎、內(nèi)容協(xié)商、異常處理等
Web MVC REST:資源服務、資源跨域、服務發(fā)現(xiàn)等
Web MVC核心:核心架構、處理流程、核心組件
Web MVC 視圖
ViewResolver
View
模板引擎
Thymeleaf
Freemarker
JSP
內(nèi)容協(xié)商
ContentNegotiationConfigurer
ContentNegotiationStrategy
ContentNegotiatingViewResolver?
異常處理
@ExceptionHandler
HandlerExceptionResolver
? ? ExceptionHandlerExceptionResolver
BasicErrorController(Spring Boot)
Web MVC REST
資源服務
? ? ? ? ? ? @RequestMapping
? ? ? ? ? ? ? ? ? @GetMapping
? ? ? ? ? ?@ResponseBody
? ? ? ? ? ?@RequestBody
資源跨域
CrossOrigin
WebMvcConfiguration#addCorsMappings
? ? ? ?傳統(tǒng)解決方案
? ? ? ? 服務發(fā)現(xiàn)
? ? Web MVC 核心
? ? 核心架構
? ? 處理流程
? ? 核心組件
? ? ? ? DispatcherServlet
? ? ? ? HandlerMapping
? ? ? ? HandlerAdapter
? ? ? ? ViewResolver
? ? ? ? ...
查看全部 -
異步非阻塞
AsyncContext asyncContext=req.startAsync();
asyncContext.start(()->{
? ? resp.getWriter().println("Hello,World");
? ? //觸發(fā)完成
? ? asyncContext.complete();
});
@Webservlet(urlPatterns = "/my/servlet",asyncSupported=true)
查看全部 -
Web應用
傳統(tǒng)servlet應用
依賴
spring-boot-starter
...web
...json? ...tomcat
Whitelabel Error page
Servlet組件
servlet
實現(xiàn)? ?@WebServlet? HttpServlet
URL映射 @WebServlet(urlPatterns="/my/servlet")
注冊 @ServletComponentScan(basePackages="com.imooc.diveinspringboot.web.servlet")
Filter
Listener
查看全部 -
????Web應用
傳統(tǒng)Servlet應用
Servlet組件:Servlet、Filter、Listener
?Servlet注冊:Servlet注解、Spring Bean、RegistrationBean
異步非阻塞:異步Servlet、非阻塞Servlet
查看全部 -
@SpringBootApplication
@EnableAutoConfiguration
spring.factories
WebMvcAutoConfiguration
嵌入式Web容器
Web Servlet:Tomcat ...
Web Reactive:Netty Web Server
生產(chǎn)準備特性
指標:/actuator/metrics
健康檢查:/actuator/health
外部化配置:/actuator/configprops
查看全部 -
? ? ? ?核心特性
Spring Boot 三大特性
組件自動裝配:Web MVC、Web Flux 、JDBC等
嵌入式Web容器:Tomcat、Jetty以及 Undertow
生產(chǎn)準備特性:指標、健康檢查、外部化配置等
查看全部 -
課程介紹
課程內(nèi)容
核心特性
web應用
數(shù)據(jù)相關
功能擴展
運維管理
課堂總結
查看全部 -
運維管理
查看全部 -
功能擴展
查看全部 -
關系型數(shù)據(jù)
查看全部 -
Web Server
查看全部 -
Spring 5 支持
對 Servlet 的補充
是 Web 應用從同步阻塞編程到異步非阻塞編程的一種轉(zhuǎn)變,即編程模型的升級
Java Lambda 是 Reactor 的基礎。
Reactor 是 Reactive Stream 的一種實現(xiàn)。其他的實現(xiàn)方式有 JDK 9 的 Flow API。
查看全部
舉報