image
- springboot项目中是否使用过EnableCaching
image
下面咱们按照springboot的方式 编写EnableLogging
- @Import(LogImportSelector.class)
image
- LogImportSelector
image
- 使用EnableLogging
image
总结
1.@Import用来导入一个或多个类(会被spring容器托管),或者配置类(配置类里面的bean都会被spring容器托管)
2. ImportSelector 该接口的方法的返回值都会被纳入到spring容器管理中
@Import
image
-
import可以采用importselecor的返回值加入到spring容器
-
import还可以自定义ImportBeanDefinitionRegistrar接口,通过BeanDefinitionRegistry纳入到spring容器
链路跟踪
spring-cloud-sleuth-core
image
网关传递traceid
image
方法拦截器设置traceid
image
aop处理traceid
image
traceid处理
image
feign处理traceid
image
RestTemplate处理traceid
image
api-gateway
image
auth-server
image
grep -rn
image
HP@owen /cygdrive/d/open-capacity-platform
$ grep -rn a26003208271fd94 *
logs/auth-gateway/auth-gateway-info.log:740:[auth-gateway:130.75.131.208:9200] [a26003208271fd94] [a26003208271fd94] 2019-09-06 09:38:33.898 INFO 6364 [XNIO-2 task-3] com.open.capacity.client.filter.ResponseFilter request url = http://127.0.0.1:9200/api-auth/validata/code/1263967C-FED7-4732-86D7-8CC6BDF752F5, traceId = a26003208271fd94
logs/auth-gateway/auth-gateway-info.log:741:[auth-gateway:130.75.131.208:9200] [a26003208271fd94] [a26003208271fd94] 2019-09-06 09:38:36.703 INFO 6364 [XNIO-2 task-3] com.open.capacity.client.filter.ResponseFilter response url http://127.0.0.1:9200/api-auth/validata/code/1263967C-FED7-4732-86D7-8CC6BDF752F5, traceId = a26003208271fd94
oauth-center/logs/auth-server/auth-server-info.log:722:[auth-server:130.75.131.208:8000] [a26003208271fd94] [b26ed6e6877dd47a] 2019-09-06 09:38:34.795 INFO 15168 [http-nio-8000-exec-1] com.open.capacity.log.aop.LogAnnotationAOP 开始请求,transid=a26003208271fd94, url=com.open.capacity.uaa.server.controller.ValidateCodeController/createCode , httpMethod=null, reqData=[“1263967C-FED7-4732-86D7-8CC6BDF752F5”]
oauth-center/logs/auth-server/auth-server-info.log:723:[auth-server:130.75.131.208:8000] [a26003208271fd94] [b26ed6e6877dd47a] 2019-09-06 09:38:36.671 INFO 15168 [http-nio-8000-exec-1] com.open.capacity.log.aop.LogAnnotationAOP 请求完成, transid=a26003208271fd94, 耗时=1898, resp=null:
image
CompletableFuture.runAsync 与链路跟踪
image
[test-log-center:130.75.131.208:8080] [,d1d8bf482db0af10] 2019-09-16 13:40:25.181 INFO 18088 [http-nio-8080-exec-10] com.open.capacity.log.test.controller.TestController ok
[test-log-center:130.75.131.208:8080] [,d1d8bf482db0af10] 2019-09-16 13:40:25.220 INFO 18088 [pool-1-thread-1] com.open.capacity.log.test.controller.TestController oook
- 异步传递MDC
image
- CompletableFuture 绑定自定义TaskExecutor
image
X-B3-TraceId生产的源头
image
image
image
image
image
CompletableFuture.runAsync 与事物问题
最后
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,不论你是刚入门Java开发的新手,还是希望在技术上不断提升的资深开发者,这些资料都将为你打开新的学习之门!
如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
177)]
[外链图片转存中…(img-oGfFnfrT-1715863187177)]
[外链图片转存中…(img-bFklQl3m-1715863187178)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,不论你是刚入门Java开发的新手,还是希望在技术上不断提升的资深开发者,这些资料都将为你打开新的学习之门!
如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!