随笔分类 -  springboot

spring bean 循环依赖问题,在本地环境可以,测试环境报循环依赖问题
摘要:spring 在某些情况下是存在这样的问题:https://github.com/spring-projects/spring-framework/issues/18879https://github.com/spring-projects/spring-framework/issues/24325 阅读全文
posted @ 2021-05-13 14:54 快鸟 阅读(4105) 评论(0) 推荐(0) 编辑
@EnableAutoConfiguration 和 @Import 的原理
摘要:(version:springboot 2.3.2) @EnableAutoConfiguration 的作用 @EnableAutoConfiguration 的作用是开启 Spring 应用上下文的自动配置,它会尝试去猜测和配置我们所需要的 bean。 例如:如果我们的 classpath 中有 阅读全文
posted @ 2020-08-29 19:48 快鸟 阅读(4021) 评论(0) 推荐(1) 编辑
Spring PropertySources 与 PropertySource
摘要:org.springframework.core.env.PropertySources 是多个 org.springframework.core.env.PropertySource 的集合,是 spring 管理和保存属性配置的关键接口。SpringBoot 在启动时,会通过 PropertyS 阅读全文
posted @ 2020-07-27 09:03 快鸟 阅读(1638) 评论(0) 推荐(1) 编辑
SpringBoot 使用技巧与心得
摘要:1. 配置类有3次机会可以去覆盖配置,这对于框架封装是很有好处的 1 // 2. 在 bean 生成后,populateBean() 时,在 application.yml 配置文件里面进行覆盖 2 @ConfigurationProperties(prefix = "cas") 3 public 阅读全文
posted @ 2020-07-24 11:12 快鸟 阅读(674) 评论(0) 推荐(0) 编辑
SpringBoot jar in jar 加载资源的原理及带来的问题
摘要:使用 IDEA 运行 springboot 程序与 java -jar 运行 springboot 程序时 ClassLoader 不同,导致 classloader.getResource() 拿不到资源 使用 this.getClass().getClassLoader() 获取 classlo 阅读全文
posted @ 2020-06-20 16:39 快鸟 阅读(2372) 评论(1) 推荐(0) 编辑
SpringBoot Bean 扫描注册核心之:ConfigurationClassPostProcessor 详解
摘要:(SpringBoot 版本:2.2.2.RELEASE) 可以说 @Configuration 是 SpringBoot 配置的基石,自然 @Configuration 类的处理是很有必要研究的。 @Configuration 类的处理是由 ConfigurationClassPostProces 阅读全文
posted @ 2020-04-16 21:42 快鸟 阅读(2444) 评论(0) 推荐(0) 编辑
根据条件加载 bean:即 @ConditionalOnXxx 的解析
摘要:(version: SpringBoot 2.2.2.RELEASE) 加载 @Configration 类,或者 @Configuration 类里面的 beanMethod 时,通常会用到条件加载,即:@CondtionalOnXxx 1. org.springframework.context 阅读全文
posted @ 2020-03-07 00:05 快鸟 阅读(2608) 评论(0) 推荐(1) 编辑
@Configuration 配置类排序
摘要:(version: SpringBoot 2.2.2.RELEASE) SpringBoot 会对 spring.factories 中的 @Configuration 类进行排序。注意:只是对所有 spring.factories 中的 @Configuratin 类排序(也就是通常使用的 sta 阅读全文
posted @ 2020-03-06 23:46 快鸟 阅读(4485) 评论(0) 推荐(0) 编辑
SpringBoot外部化配置本地调试
摘要: 阅读全文
posted @ 2020-03-02 17:34 快鸟 阅读(495) 评论(0) 推荐(0) 编辑
Spring 配置项解析: @Value vs @ConfigurationProperties
摘要:@ConfigurationProperties vs @Value https://docs.spring.io/spring-boot/docs/2.2.2.RELEASE/reference/htmlsingle/#boot-features-external-config-vs-value 阅读全文
posted @ 2020-01-19 14:46 快鸟 阅读(1155) 评论(0) 推荐(0) 编辑
SpringBoot 配置项解析 && @PropertySource 注解的处理
摘要:SpringBoot 的配置解析是通过 Environment 来实现的。 Environment:与属性相关的 Environment 对象的作用是为用户提供一个方便的服务接口,用于配置属性源并从中解析属性。 Environment 本身实现了 PropertyResolver 接口,最终会委托给 阅读全文
posted @ 2020-01-02 13:58 快鸟 阅读(1534) 评论(0) 推荐(0) 编辑
SpringBoot 启动流程
摘要:(Version: 2.1.0.RELEASE) 1. 启动入口 @SpringBootApplication public class KvnMainApplication { public static void main(String[] args) { // 1. 创建和初始化 Spring 阅读全文
posted @ 2019-12-25 11:15 快鸟 阅读(682) 评论(0) 推荐(0) 编辑
springboot踩坑记
摘要:1. @ConditionalOnProperty 根据配置加载不同的 bean 场景:对 redis 配置进行封装,实现自动化配置,能兼容哨兵模式和集群模式。想到在 redis 配置中加一个 redis.type 来区分集群和哨兵模式(redis.type=cluster 或 sentinel), 阅读全文
posted @ 2019-11-20 16:15 快鸟 阅读(1899) 评论(0) 推荐(0) 编辑
springboot logback 集成
摘要:在 application.yml 中敲 logging.pattern.consle ,IDEA 会联想到对应的值。单击属性就可以跳到 LoggingApplicationListener.java 。在 spring-boot.jar 中搜索 %clr(%d{yyyy-MM-dd HH:mm:s 阅读全文
posted @ 2018-09-30 17:26 快鸟 阅读(227) 评论(0) 推荐(0) 编辑
SpringBoot-服务端参数验证-JSR-303验证框架
摘要:1. springboot 默认集成了 hibernate-validator,它默认是生效的,可以直接使用。 比如: @RestController @RequestMapping("/hibernate") public class DefaultHibernateValidatorTestCo 阅读全文
posted @ 2018-08-21 16:27 快鸟 阅读(4833) 评论(0) 推荐(0) 编辑
【转载】springboot + swagger
摘要:注:本文参考自 http://www.jianshu.com/p/0465a2b837d2 https://www.cnblogs.com/java-zhao/p/5348113.html swagger用于定义API文档。 好处: 前后端分离开发 API文档非常明确 测试的时候不需要再使用URL输 阅读全文
posted @ 2018-06-28 16:22 快鸟 阅读(361) 评论(0) 推荐(0) 编辑
解决Spring Boot中,通过filter打印post请求的 request body 问题
摘要:http://slackspace.de/articles/log-request-body-with-spring-boot/ (filter + RequestWrapper:最优雅的写法) https://howtodoinjava.com/servlets/httpservletreques 阅读全文
posted @ 2018-06-21 12:45 快鸟 阅读(3933) 评论(0) 推荐(0) 编辑
SpringBoot自动配置xxxAutoConfiguration 的使用
摘要:https://sdqali.in/blog/2016/07/16/controlling-redis-auto-configuration-for-spring-boot-session/ 常用的类: @ConditionalOnProperty(name = "use.redis.session 阅读全文
posted @ 2018-06-12 15:02 快鸟 阅读(7689) 评论(0) 推荐(0) 编辑