日期:2014-05-18  浏览次数:20659 次

AOP 注解问题
本帖最后由 lalashuai666 于 2013-03-29 13:14:25 编辑
package com.chuanghe.web.utils;

import javax.xml.rpc.ServiceException;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ReimDvisor {
@Pointcut("execution (* com.chuanghe.web.action.reim.ReimManageAction.doStampRecord(..))")
public void recordAction() {

System.out.print("===========");
}
@AfterReturning("recordAction()")
public void test(){
System.out.print("----------------");
}

}

spring 配置

<?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:aop="http://www.springframework.org/schema/aop"    
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">                          
<context:component-scan base-package="com.chuanghe" />  
<aop:aspectj-autoproxy/> 

........省略
不知道怎么回事  打印不出来
aop spring

------解决方案--------------------
@Controller
@Component
不要加东西。
------解决方案--------------------
你在一个类中搞来搞去的。没有理解切面到底是干嘛用的