@Value获取值和@ConfigurationProperties获取值比较:
@PropertySource、@ImportResource、@Bean:
${random.value}、${random.int}、${random.long}${random.int(10)}、${random.int[1024,65536]}person.last-name=张三${random.uuid}person.age=${random.int}person.birth=2017/12/15person.boss=falseperson.maps.k1=v1person.maps.k2=14person.lists=a,b,cperson.dog.name=${person.hello:hello}_dogperson.dog.age=15Profile:
外部配置加载顺序:
SpringBoot也可以从以下位置加载配置;优先级从高到低;高优先级的配置覆盖低优先级的配置,所有的配置会形成互补配置。
规则为:①==由jar包外向jar包内进行寻找==②==优先加载带profile==③==再来加载不带profile==
自动配置原理:
=========================AUTO-CONFIGURATIONREPORT=========================Positivematches:(自动配置类启用的)-----------------DispatcherServletAutoConfigurationmatched:-@ConditionalOnClassfoundrequiredclass'org.springframework.web.servlet.DispatcherServlet';@ConditionalOnMissingClassdidnotfindunwantedclass(OnClassCondition)-@ConditionalOnWebApplication(required)foundStandardServletEnvironment(OnWebApplicationCondition)Negativematches:(没有启动,没有匹配成功的自动配置类)-----------------ActiveMQAutoConfiguration:Didnotmatch:-@ConditionalOnClassdidnotfindrequiredclasses'javax.jms.ConnectionFactory','org.apache.activemq.ActiveMQConnectionFactory'(OnClassCondition)AopAutoConfiguration:Didnotmatch:-@ConditionalOnClassdidnotfindrequiredclasses'org.aspectj.lang.annotation.Aspect','org.aspectj.lang.reflect.Advice'(OnClassCondition)日志日志框架:
市面上的日志框架;
如何在系统中使用SLF4j:
以后开发的时候,日志记录方法的调用,不应该来直接调用日志的实现类,而是调用日志抽象层里面的方法。
给系统里面导入slf4j的jar和logback的实现jar
SpringBoot日志关系:`
springboot的jar包目录结构分析:
thymeleaf的使用:
Springboot2.x与1.xWebMvc配置的区别(WebMvcConfigurer):
错误处理机制:
如何定制错误的json数据;
配置嵌入式Servlet容器:
//使用WebMvcConfigurerAdapter可以来扩展SpringMVC的功能//@EnableWebMvc不要接管SpringMVC@ConfigurationpublicclassMyMvcConfigextendsWebMvcConfigurerAdapter{@OverridepublicvoidaddViewControllers(ViewControllerRegistryregistry){//super.addViewControllers(registry);//浏览器发送/atguigu请求来到successregistry.addViewController("/atguigu").setViewName("success");}//所有的WebMvcConfigurerAdapter组件都会一起起作用@Bean//将组件注册在容器publicWebMvcConfigurerAdapterwebMvcConfigurerAdapter(){WebMvcConfigurerAdapteradapter=newWebMvcConfigurerAdapter(){@OverridepublicvoidaddViewControllers(ViewControllerRegistryregistry){registry.addViewController("/").setViewName("login");registry.addViewController("/index.html").setViewName("login");}};returnadapter;}}配置国际化:
thymeleaf公共页面元素抽取:
核心概念:
使用Docker的步骤:
安装Docker:
devtools工具包使用:
使用介绍:
#打开所有端点management:endpoints:web:exposure:include:"*"#调整端点的前缀路径为/management:endpoints:web:base-path:/#显示健康具体信息默认不会显示详细信息management:endpoint:health:show-details:always