前言

aop作为spring的一个强大的功能经常被使用,aop的应用场景有很多,但是实际的应用还是需要根据实际的业务来进行实现。这里就以打印日志作为例子,在SpringBoot中配置aop
已经加入我的github模版中:https://github.com/LinkinStars/springBootTemplate

配置

经过那么长时间的过程,我们也慢慢体会到,在spingboot项目中添加元素是非常方便的,aop也是。

首先配置依赖
compile('org.springframework.boot:spring-boot-starter-aop')

然后就是添加aop了

 @Component
@Aspect
public class DemoAop { @Pointcut("execution(* com.linkinstars.springBootTemplate.controller.*.*(..))")
private void logPointcut(){} @Before("logPointcut()")
public void before(JoinPoint joinPoint){
LogUtil.printLog("AOP的before方法执行");
}
}

最后在我们访问任何controller的时候就会打印相应的日志信息


具体切点的配置,以及切入的方法等,都和原来是一样的这里就不在赘述

详细配置说明参数参考:https://www.cnblogs.com/lic309/p/4079194.html

最新文章

  1. SQLite -- 分页查询
  2. Atitit数据库层次架构表与知识点 attilax 总结
  3. [转]linux 系统监控、诊断工具之 IO wait
  4. STUN和TURN技术浅析
  5. poj 2325 Persistent Numbers
  6. OC面向对象封装
  7. Fedora下载地址
  8. 【memset】关于memset的初始最大最小值
  9. NPM与调试工具的使用
  10. Linux配置完iptables后,重启失效的解决方案
  11. ELK学习笔记之logstash安装logstash-filter-multiline(在线离线安装)
  12. linux系统mysql主从配置
  13. Announcing the Operate Preview Release: Monitoring and Managing Cross-Microservice Workflows
  14. Java的synchronized的同步代码块和同步方法的区别
  15. 【Udacity并行计算课程笔记】- Lesson 3 Fundamental GPU Algorithms (Reduce, Scan, Histogram)
  16. Environment error: “CodeBloks can't find compiler executable in your configured search path's for GNU GCC compiler”
  17. Uva 11520 - Fill the Square 贪心 难度: 0
  18. C# webbrowser判断页面是否加载完毕
  19. Ubuntu系统下Jenkins的本地构建基本方法
  20. STL源码分析-hashtable

热门文章

  1. 一、Html简介
  2. TP手册学习第三天
  3. awk匹配以aaa开头,以bbb结尾的内容,同时aaa和bbb之间还包含ccc
  4. MySQL--如何快速对比数据
  5. Java并发系列[4]----AbstractQueuedSynchronizer源码分析之条件队列
  6. C#使用Redis
  7. selenium的使用技巧及集成到scrapy
  8. 小白学Docker之Swarm
  9. SpringMVC源码情操陶冶-AbstractUrlHandlerMapping
  10. BZOJ 3551: [ONTAK2010]Peaks加强版 [Kruskal重构树 dfs序 主席树]