您的位置:首页 > 编程语言 > Java开发

Spring Boot 自定义注解

2017-08-03 08:18 567 查看
前情回顾:

Spring MVC AOP通过注解方式拦截Controller等实现日志管理

1、添加spring boot引用

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>


2、在spring boot的Application启动类中使用@EnableAspectJAutoProxy注解,添加对Aspectj支持

3、与前情回顾编写类似的OperationLogger、SysLogAspect

4、在需要使用的方法上添加 @OperationLogger注解,搞定

个人微信公众号:



作者:jiankunking 出处:http://blog.csdn.net/jiankunking
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息