没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
【古墓】SpringBoot = 概念.................................................................................................1
SpringBoot .........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
xsl-fo ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【游戏厅】SpringBoot = 核心配置 ......................................................................................1
配置加载 ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
application.yml ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
spring.factories ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【老街】SpringBoot = org.springframework.boot(源码包) .......................................1
原始包..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
SpringApplication...............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
SpringApplicationRunListener............................................................................................................................................................................................................................................................................................................................................................................................................................................1
CommandLineRunner ........................................................................................................................................................................................................................................................................................................................................................................................................................................................1
ApplicationRunner .............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
WebApplicationType .........................................................................................................................................................................................................................................................................................................................................................................................................................................................1
SpringBootVersion .............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
web......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
RegistrationBean................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
DynamicRegistrationBean..................................................................................................................................................................................................................................................................................................................................................................................................................................................1
AbstractFilterRegistrationBean..........................................................................................................................................................................................................................................................................................................................................................................................................................................1
FilterRegistrationBean .......................................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
test.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
context ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
ApplicationContextInitializer .............................................................................................................................................................................................................................................................................................................................................................................................................................................1
ApplicationListener ............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
ConfigurationPropertiesBindingPostProcessor..................................................................................................................................................................................................................................................................................................................................................................................................................1
SpringApplicationEvent......................................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
autoconfigure ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
AutoConfigurationImportSelector .....................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
security...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
scheduling.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
AsyncConfigurer.................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【医疗仓】SpringBoot = org.springframework.cloud(SpringCloud 源码包)............1
context ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
loadbalancer ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
RoundRobinLoadBalancer..................................................................................................................................................................................................................................................................................................................................................................................................................................................1
openfeign..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
注解 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
BaseRequestInterceptor ....................................................................................................................................................................................................................................................................................................................................................................................................................................................1
FeignAcceptGzipEncodingInterceptor ...............................................................................................................................................................................................................................................................................................................................................................................................................................1
FeignContentGzipEncodingInterceptor .............................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房】SpringBoot = 第三方包..........................................................................................1
【卧房-罐子】核心 ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
启动类 ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
添加核心依赖 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
父工程 依赖管理 ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
自定义启动器 starter........................................................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-cloud-starter-bootstrap(配置) ..........................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-boot-devtools(开发)..........................................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-boot-starter-actuator(监控)..............................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-boot-admin-starter-server(监控)......................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-镜子】数据存储...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
原理..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis-3.5.3 源码解析......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis-spring-2.0.3 源码解析 .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis-3.4.5 源码解析......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
test 使用 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis 使用.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
配置项 .....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis-plus.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
pagehelper.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis 逆向生成..............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mybatis-plus 逆向生成代码..............................................................................................................................................................................................................................................................................................................................................................................................................................................1
jpa ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
原理..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
entity 使用 .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
entityListener 使用..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
dao 使用.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
repository 使用 ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mongo................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
radis ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
rabbitmq ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
activemq ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
kafka...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
elasticsearch ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
zookeeper ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
mysql-connector-java ........................................................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-boot-starter-data-jdbc ............................................................................................................................................................................................................................................................................................................................................................................................................................................1
sprint-boot-starter-data-jpa ..............................................................................................................................................................................................................................................................................................................................................................................................................................................1
druid...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
c3p0 ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-遮帘】安全 ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
java-jwt ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
rsa ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-security-acl(jar) .................................................................................................................................................................................................................................................................................................................................................................................................................................................1
jasypt-spring-boot-starter..................................................................................................................................................................................................................................................................................................................................................................................................................................................1
spire.xls.free.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-灯笼】微服务.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
Ribbon 负载均衡...............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
Feign 服务调用..................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
Hystrix 熔断器...................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-凳子】功能扩展...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
junit....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
aop .....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
概念..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
源码解析 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
使用..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
netty...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
reactor ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
swagger..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
sprongdoc-openapi-ui........................................................................................................................................................................................................................................................................................................................................................................................................................................................1
velocity...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
thymeleaf...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
servlet ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
webflux ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
logging................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
com.fasterxml.jackson .......................................................................................................................................................................................................................................................................................................................................................................................................................................................1
javers-core .........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
ehcache..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
dockerfile-maven-plugin....................................................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-boot-starter-mail ....................................................................................................................................................................................................................................................................................................................................................................................................................................................1
xxl-job ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
hazelcast-spring .................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
libphonenumber(电话号码) ........................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-床】数据工具.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
lombok ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
fastjson ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
jackson ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
javers..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
dozer ..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
commons-lang3 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
commons-collections4.......................................................................................................................................................................................................................................................................................................................................................................................................................................................1
commons-beanutils ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................1
commons-io .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
commons-configuration2 ..................................................................................................................................................................................................................................................................................................................................................................................................................................................1
commons-configuration ....................................................................................................................................................................................................................................................................................................................................................................................................................................................1
hutool.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
Gson...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
guava..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
joda-time............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
transmittable-thread-local.................................................................................................................................................................................................................................................................................................................................................................................................................................................1
SXSSFWorkbook.................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
hibernate-validator............................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-板子】文件处理...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
itextpdf ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
poi-ooxml(读写 excel)..................................................................................................................................................................................................................................................................................................................................................................................................................................................1
apache-fop.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-窗户】日志 ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
logback...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
log4j ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
log4jdbc .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【卧房-书桌】插件 ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
maven-source-plugin(maven 工具) .............................................................................................................................................................................................................................................................................................................................................................................................................................1
maven-surefire-plugin(maven 工具)............................................................................................................................................................................................................................................................................................................................................................................................................................1
maven-compiler-plugin(maven 工具)..........................................................................................................................................................................................................................................................................................................................................................................................................................1
spring-boot-maven-plugin(项目配置) .........................................................................................................................................................................................................................................................................................................................................................................................................................1
tomcat7-maven-plugin(项目配置)...............................................................................................................................................................................................................................................................................................................................................................................................................................1
jfx 图形化 ..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................1
【古墓】SpringBoot = 概念
SpringBoot
自动装配原理: @SpringBootApplication 下包含注解@EnableAutoConfiguration
底层使用 AutoConfigurationImportSelector 的 getCandidateConfigurations 初始化一些 spring.factories 内的 bean
SpringApplication 启动类在开始时也会初始化一些 spring.factories 内的 bean
xsl-fo
函数 substring($data, $counter, 1) concat(a, "​") length()
结构标签——————————————————————————————————————————————————
<xsl:template match="/"> 匹配所有数据对象
<xsl:apply-templates select="ProductPdfInfo" /> 数据对象
<xsl:param name="data" select="0" /> 定义变量
<xsl:template match="ProductPdfInfo"> 引用上方数据对象,也可以匹配所有数据对象
<fo:root> 根节点【xml:lang="en" 语言 xmlns:fo="http://www.w3.org/1999/XSL/Format" 指定 fo 格式化】
root 内部结构标签————————————————————————————————————————————————
<fo:layout-master-set> 页面容器
<fo:simple-page-master> 一个简单页面【master-name="tt" 页面名称】
<fo:region-body> body 容器
<fo:page-sequence> 主要内容 【master-reference="tt" 对应的页面容器】
<fo:flow> 流动容器【flow-name="xsl-region-body" 对应的页面内部 body 容器】
<fo:inline-container> 行内容器【inline-progression-dimension="15.0%" 宽度占比】
<fo:block-container> 块容器
<fo:block> 块元素【keep-together.within-page="always"】
元素标签——————————————————————————————————————————————————
<fo:external-graphic> 图片元素【xf:alt-text="Citi Logo" 提示文字】
<fo:list-item> 包含列表中的每个项目
<fo:list-item-label> 包含用于 list-item 的标签 - 典型地,包含一个数字或者字符的 <fo:block>
<fo:list-item-body> 包含 list-item 的内容/主体 - 典型地,一个或多个 <fo:block> 对象
<xsl:if test="(pdfGenerationRequest/accountReconPdfData)" 存在时才渲染内部内容
<xsl:for-each select="pdfGenerationRequest/myList"> 遍历
<xsl:with-param name="achPage" select="achPage"> 引用元素对象中的字段值
<xsl:if test="position() !=last()" 索引不是最后一个时
<xsl:if test="position() >=2)" 索引大于等于 2 时
<xsl:value-of select="pdfGenerationRequest/form/accountText"> 引用 transform 中 src 的数据
<xsl:value-of select="contactNumber[phoneType='MOBILE'][position()='1'] "> 选出 phoneType='MOBILE'的数据,并且是第一个
<xsl:value-of select="pdfGenerationRequest/form/ownerships[formater:checkOwnerType(ownerType/text(), 'ACCOUNT_SIGNER') =Yes'] [signerType=''RESOLUTION_AUTHORITY"] > 调用 formater 的方法返回值
<xsl:call-template name="account-reconciliation"> 引入其他 template
公共样式——————————————————————————————————————————————————
margin-bottom="1.5cm" 下边距
margin="0 1 2 3"
text-align="center" 中间对齐
border="1px solid green" 边框
代码使用——————————————————————————————————————————————————
// Setup directories
File baseDir = new File(".");
File outDir = new File(baseDir, "out");
outDir.mkdirs();
// Setup input and output files
File xmlfile = new File(baseDir, "xml/xml/projectteam.xml");
File xsltfile = new File(baseDir, "xml/xslt/projectteam2fo.xsl");
File pdffile = new File(outDir, "ResultXML2PDF.pdf");
// configure fopFactory as desired
final FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltfile)); //开始处理 原始 xsl 文件
// Set the value of a <param> in the stylesheet
transformer.setParameter("versionParam", "2.0");
// Setup input for XSLT transformation(数据对象,可以是对象)
Source src = new StreamSource(xmlfile);
// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}
【游戏厅】SpringBoot = 核心配置
配置加载
内部配置文件加载顺序
1. file:./config/ 当前项目下的/config 目录下(必须位于当前工程根目录,多个大工程嵌套时会找最根部的 config 目录)
2. file:./ 当前项目的根目录
3. classpath:/config/ classpath 的/config 目录
4. classpath:/ classpath 的根目录
外部配置文件加载顺序
1. jar 所在目录
application.yml
application.yml 或 application.properties 或 application.yaml 项目默认配置文件(在同一级目录下优先级为: properties > yml > yaml)
加载优先级:application-dev.yml > application.yml
YAML 语法:大小写敏感,
数值前必须有空格
缩进不能用 Tab,只能用空格
单引号字符串忽略转义'hello \n word'
server:
port: 8099 启动端口
--- 单个文件内多文件开始语法
server:
port: 8066
… 单个文件内多文件结尾语法
servlet:
context-path: /springboot-demo 访问项目根路径
multipart:
enabled: true
max-file-size: 10MB
max-request-size: 15MB
tomcat:
uri-encoding: utf-8
basedir: /usr/tmp/tomcat
accesslog:
enabled: false
directory: logs 日志文件所在目录,没有就创建,可以是绝对路径或相对路径
buffered: true 缓存输出(周期性 flush)
patterm: common 日志输出格式
suffix: .log 日志后缀
prefix: access_log 日志前缀
rotate: true 日志旋转
spring:
main:
allow-circular-references: true 关闭循环依赖
profiles:
active: dev 激活的其他的配置文件 application-dev.yml(application.yml 或 application.properties 一直生效)
mvc:
static-path-pattern: /res/** 定义根目录访问静态资源的 url 路径,在 resource 目录下(会导致 welcom 页失效,index 默认页面失效)
hiddenmethod:
filter:
enable: true 可以通过表单 psot 方式提交的值决定请求方式<input name="_method" value="put"/>
resources:
static-location: [classpath:/stac] 静态资源存放目录(favicon.ico 项目图标)
add-mappings: true 启用静态资源访问
cache:
period: 11000 缓存时间
servlet:
multipart:
max-file-size: 10MB multipart/form-dta 请求 单个文件最大值
max-request-size: 100MB multipart/form-dta 请求 单次请求文件总最大值
my-car: 自定义类配置(不用加引号 ,‘ - ’分割命名)
userName: zhangsan 字符串
boss: true 布尔值
a: [xxx, sss] 数组
arr: 数组
- xxx
- sss
obj: { a:80, b:90} 对象
obj: 对象
a: 80
b: 90
routes: 对象数组
- id: template
uri: http://127.0.0.1:8099
predicates:
- Path=/api-template/**
filters:
- StripPrefix=1
- id: generator
uri: lb://boss-generator
predicates:
- Path=/api-generator/**
filters:
- StripPrefix=1
person:
name: ${my-car.obj.a} 引用上面定义的 my-car
spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.saidake.redis.config.MyAutoConfiguration 装载自定义自动配置类的 bean
org.springframework.context.ApplicationContextInitializer=com.saidake.redis.config.MyApplicationContextInitializer
org.springframework.boot.SpringApplicationRunListener=com.saidake.redis.config.MySpringApplicationRunListener
【老街】SpringBoot = org.springframework.boot(源码包)
原始包
SpringApplication
package org.springframework.boot;
public class SpringApplication 核心引导类,所有的事件都是在此对象上产生(2.1.17.RELEASE)
public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) { 构造函数
primarySources 引导类的 class
this.resourceLoader = resourceLoader;
Assert.notNull(primarySources, "PrimarySources must not be null");
this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
this.webApplicationType = WebApplicationType.deduceFromClasspath(); 判断 web 环境
setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class)); 从 spring.factories 里实例化程序初始化构造器 ApplicationContextInitializer 的实现类,并设置到当前成员 initializers 中
setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); 从 spring.factories 里实例化程序监听器 ApplicationListener 的实现类,并设置到当前成员 listeners 中
this.mainApplicationClass = deduceMainApplicationClass(); 找到 main 函数所在类
}
public ConfigurableApplicationContext run(String... args) {
StopWatch stopWatch = new StopWatch(); 创建一个计时器
stopWatch.start(); 开始计时
ConfigurableApplicationContext context = null; 定义 IOC 容器
Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>(); 定义项目启动过程的异常分析器
configureHeadlessProperty(); 设置一个 java.awt.headless 系统属性,无头启动(没有显示器启动)
SpringApplicationRunListeners listeners = getRunListeners(args); 从 spring.factories 里实例化 SpringApplicationRunListener 的实现类,并放入此容器
listeners.starting(); 调用所有 SpringApplicationRunListener 的 starting 方法
try {
ApplicationArguments applicationArguments = new DefaultApplicationArguments(args); 封装应用参数信息
ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments); 准备环境,加载属性文件资源,调用所有 SpringApplicationRunListener 的 environmentPrepared 方法
configureIgnoreBeanInfo(environment); 通过属性 spring.beaninfo.ignore 确认是否跳过对 BeanInfo 类的搜索
Banner printedBanner = printBanner(environment); 打印 logo 图标 banner.txt
context = createApplicationContext(); 创建 IOC 容器
exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class, new Class[] { ConfigurableApplicationContext.class }, context); 从 spring.factories 里实例化 SpringBootExceptionReporter 的实现类
prepareContext(context, environment, listeners, applicationArguments, printedBanner); 准备容器,加载配置环境,ResourceLoader 资源加载器,配置监听,加载启动参数(执行后 IOC 容器创建好了,bean 还没全部加载进来)
调用所有 SpringApplicationRunListener 的 contextPrepared 和 contextLoaded 方法
refreshContext(context); 刷新容器,参照 spring 源码,准备环境所需的 bean 工厂,通过工厂产生环境所需的 bean(执行后去配置里寻找有哪些 bean 需要创建)
afterRefresh(context, applicationArguments); 空函数,可以自定义实现
stopWatch.stop(); 结束计时,计算项目启动耗时
if (this.logStartupInfo) {
new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);
}
listeners.started(context); 调用所有 SpringApplicationRunListener 的 started 方法
callRunners(context, applicationArguments); 加载完成,执行 bean 监听器,调用 CommandLineRunner 和 ApplicationRunner
} catch (Throwable ex) {
handleRunFailure(context, ex, exceptionReporters, listeners);
throw new IllegalStateException(ex);
}
try {
listeners.running(context); 调用所有 SpringApplicationRunListener 的 running 方法
} catch (Throwable ex) {
handleRunFailure(context, ex, exceptionReporters, null); 处理运行失败,调用所有 SpringApplicationRunListener 的 failed 方法
throw new IllegalStateException(ex);
}
return context; 返回 IOC 容器
}
static WebApplicationType deduceFromClasspath() 推测是否是 web 环境,通过寻找一些 web 环境的类
都存在就是 REACTIVE: DispatcherHandler,DispatcherServlet,ServletContainer
都存在就是 SERVLET: Servlet,ConfigurableWebApplicationContext
任何一个不存在就是 NONE: Servlet,ConfigurableWebApplicationContext
private Class<?> deduceMainApplicationClass() 推测 main 函数所在类(新建了一个运行异常对象,通过这个对象获取当前的调用函数堆栈数组 StackTrace,之后遍历这个堆栈数组元素的成员方法名,找到方法名为 main 的类,返回这个类)
剩余86页未读,继续阅读
资源评论
saidake
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功