OpeningO-spring-boot-x Spring Boot 扩展开源项目

我要开发同款
匿名用户2020年08月12日
30阅读
开发技术Java
所属分类Web应用开发、Web框架
授权协议MIT

作品详情

spring-boot-x是springboot应用的扩展。

特性清单

手动事务管理[2021.6.29更新]

分布式id生成器gedid,DidLoader[2021.6.25更新]

Safety工具[2021.6.25更新]

请求日志,包括请求源、请求目标、请求参数、处理时间、错误异常等信息;

请求响应参数的自动装配(映射);

跨域的配置;

嵌入SpringBoot的异常处理机制,可以将原来的错误信息中插入其他信息、或将其解析或转换为其他信息;

如SpringBoot之starter动态装配或在yml中配置相关特性;

简化的Redis操作;

提炼Elasticsearch之HighlevelClient常用操作;

feign的请求头参数的处理:合并上下游的请求头参数,并发场景的数据处理策略;

基于Druid和Hikari的动态路由RoutingDataSource;

SpringBoot应用的配置信息的自动拷贝;

1.请求日志

****************************************************************::SpringApplicationX::forcurrentrequestreportinformation****************************************************************ClientIP:127.0.0.1RequestTime:2020-07-12T19:24:40.249Controller:org.openingo.x.controller.UserController.(UserController.java:1)URI:https://localhost:8080/jsonHandler(Action):jsonMethod:GETProcessingTime:0.002sHeader(s):[user-agent:"PostmanRuntime/7.25.0",cache-control:"no-cache",postman-token:"b29a0616-7e31-4150-b022-4bf3680bf771",host:"localhost:8080",accept-encoding:"gzip,deflate,br",connection:"keep-alive",content-length:"21",Content-Type:"application/json;charset=UTF-8"]Body:{"name":"qicz"}Response:{"name":"qicz","age":18}----------------------------------------------------------------

2.错误处理

可以继承AbstractServiceErrorAttributes,扩展exception的处理

{"timestamp":"2020-07-13T05:49:06.071+0000","status":500,"error":"InternalServerError","exception":"org.openingo.spring.exception.ServiceException","message":"testingexception","path":"/ex","handler":"publicjava.util.Maporg.openingo.x.controller.UserController.ex()","openingo.error":{"ex":"org.openingo.spring.exception.ServiceException:testingexception","em":"testingexception","error":"InternalServerError","ec":"ERROR_CODE"}}

3.使用及配置

加入spring-boot-x依赖(已托管在中央仓库),在启动class上加入@EnableExtension注解即可使用spring-boot-x的扩展功能。

通过application.yml/application.properties可以对请求日志redis等操作进行开关。默认情况下,请求日志及错误扩展为开启状态。

openingo:redis:enable:truehttp:request:cors:allowed-header:"*"enable:trueallowed-all:truelog:enable:trueerror:enable:true

 

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论