Spring基础 导入AOP+自定义标签切面
来源:互联网 发布:linux 平台 编辑:程序博客网 时间:2024/06/05 01:16
maven
<!--使用AspectJ方式注解需要相应的包 --><dependency><groupId>org.aspectj</groupId><artifactId>aspectjrt</artifactId></dependency><!--使用AspectJ方式注解需要相应的包 --><dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId></dependency><!-- Spring Dependency Begin --><dependency><groupId>org.springframework</groupId><artifactId>spring-aop</artifactId></dependency>
springmvc+头文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <description>Spring MVC Configuration</description> <aop:aspectj-autoproxy></aop:aspectj-autoproxy>简单切面
@Aspect@Componentpublic class TaskLoggerAspect {private static Logger logger = LoggerFactory.getLogger(TaskLoggerAspect.class);@Before(value="@annotation(com.minstone.platform.tool.sys.annotation.TaskLoggerAnnotation)")public void beforeTask(JoinPoint joinPoint){logger.info("标签执行前");}@After(value="@annotation(com.minstone.platform.tool.sys.annotation.TaskLoggerAnnotation)")public void afterTask(JoinPoint joinPoint){logger.info("标签执行后");}@AfterThrowing(value="@annotation(com.minstone.platform.tool.sys.annotation.TaskLoggerAnnotation)")public void AfterThrowing(JoinPoint joinPoint){logger.info("标签报错后");}}简单注解
@Target(value={ElementType.METHOD})public @interface TaskLoggerAnnotation {}
0 0
- Spring基础 导入AOP+自定义标签切面
- Spring AOP自定义切面
- Spring 切面 AOP基础 之一
- Spring自定义面向切面编程(AOP)
- Spring 切面 AOP基础 之二
- Spring 切面 AOP基础 之三
- Spring 切面 AOP基础 之四
- spring aop切面编程基础实例
- Spring AOP---切面编程基础(动态代理)
- Spring AOP切面基于注解基础学习
- spring自定义标签aop实现
- Spring AOP编程中--@aspect 标签,切面编程
- aop自定义切面
- 【Spring】AOP - 面向切面
- spring aop 定义切面
- Spring AOP切面
- 【Spring】AOP - 面向切面
- Spring AOP切面编程
- poj 1716(最长路+差分约束系统)
- c++ primer 练习 2.21、2.23、2.24、2.25
- 平衡树学习笔记——旋转式treap
- 关于jQuery使用serializeArray()序列化表单数据,使用FormData()实现AJAX请求的问题
- 轻框架Jfinal基本编译熟悉
- Spring基础 导入AOP+自定义标签切面
- VB 共享软件防破解设计技术初探(一)
- Linux查看CPU信息
- maven项目:java.lang.ClassNotFoundException
- 【杭电OJ】2544--最短路(最短路)
- 求解微分方程组的ODE算法
- Python 函数
- 1.5 一级指针内存模型(初学者重点)
- 红帽6.5未安装中文语言导致数据库乱码