![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
javaweb
淳丶
这个作者很懒,什么都没留下…
展开
-
自定义注解aop实现访问接口log打印
1.自定义注解 @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Log { String value() default ""; } 2.aop实现类 @Slf4j @Aspect @Component public class LogAspect { @Resource private BaseProperties dsProperties; @Reso原创 2021-07-26 11:16:45 · 260 阅读 · 0 评论 -
执行sql日志打印拦截器实现
添加拦截器 @Slf4j @Intercepts(value = { @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBound原创 2021-07-26 11:05:02 · 405 阅读 · 0 评论 -
自定义业务异常
BusinessException public class BusinessException extends RuntimeException{ private static final long serialVersionUID = 2218515841497670864L; private Long code; protected Object data; public BusinessException() { this("操作失败!");原创 2021-07-26 10:53:52 · 161 阅读 · 0 评论 -
注解+pagehelper实现sql数据分页
1.首先声明注解@Pageable @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Pageable { int defaultPage() default 0; int defaultSize() default 10; int maxPage() default 500; int maxSize() default 100; boolean原创 2021-07-26 10:33:51 · 781 阅读 · 0 评论 -
spring-boot AOP 记录用户操作日志
实现aop方法 @Slf4j @Aspect @Component public class LogAspect { @Autowired private BaseProperties baseProperties; @Autowired private LogService logService; @Pointcut("@annotation(annotation.Log)") public void pointcut() { // d原创 2021-03-31 14:53:27 · 90 阅读 · 0 评论 -
自定义注解+AOP+Redis实现限流 (单体和分布式均适用,全局限流)
接口限流 接口限流全局操作通常使用令牌算法,漏桶算法。 这篇文章讲的较好, https://blog.csdn.net/zrg523/article/details/82185088 接入层有分布式限流,nginx限流。 本文使用注解方式在springboot中限流。 声明限流类,编写AOP实现功能 @Slf4j @Aspect @Component public class LimitAspect { private final RedisTemplate<String, Serializ原创 2021-03-31 14:50:28 · 650 阅读 · 0 评论 -
spring微服务解决跨域问题
一、使用注解@CrossOrigin controller方法的CORS配置,您可以向@RequestMapping注解处理程序方法添加一个@CrossOrigin注解,以便启用CORS,放在类上对类下面所有方法生效,spring会整合类和方法上的参数。(默认情况下,@CrossOrigin允许在@RequestMapping注解中指定的所有源和HTTP方法): @RestController @CrossOrigin(origins = "http://domain2.com", maxAge = 36原创 2021-03-26 15:10:18 · 185 阅读 · 0 评论 -
spring-boot使用拦截器添加http、https请求日志,传递header
添加http拦截器 @Component("RestTemplateInterceptor") @Order(value = 2) @Slf4j public class RestTemplateInterceptor implements ClientHttpRequestInterceptor { @Override public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpR原创 2021-03-26 14:54:03 · 708 阅读 · 0 评论 -
spring-boot+Mybatis使用拦截器打印sql
配置拦截器核心@Intercepts注解 @Slf4j @Intercepts(value = { @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}), @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.原创 2021-03-26 14:35:00 · 871 阅读 · 0 评论