你是怎么配置Spring的AOP的?能把配置文件贴出来吗?

解决方案 »

  1.   

    这是和AOP有关的配置:
    //开启自动代理
    <aop:aspectj-autoproxy/>
    //部署一个测试action
    <bean id="testAction" name="/test" class="com.abc.action.TestAction"/>
    //部署一个切面类
    <bean class="com.abc.action.ActionLayerAspect"/>
    我是参照Spring2.0的官方参考手册一步步做的,就是找不出原因,迷茫中。
    另外,现在Spring2.0的资料比较少,希望能找一个志同道合的朋友一起学习,
    我的QQ:121440879
      

  2.   

    所有的类前面加@Aspect声明如@Aspect
    public class ActionLayerAspect{
    .......
    }
      

  3.   

    @Aspect我加了呀!
    我现在在xml文件中配置AOP已经成功了:
    <bean
        id="actionLayerAspect"
        class="com.abc.aspect.ActionLayerAspect"/>
    <aop:config>
        <aop:aspect ref="actionLayerAspect">
            <aop:before
                pointcut="execution(* com.abc.action.*Action.*(..))"
                method="doPreAction"/>
        </aop:aspect>
    </aop:config>
    但我就是不知道为什么用注释式的AOP就不行呢,好像编译器忽略了@Aspect
      

  4.   

    请教各位高手,我是按照下面的方式设定的,为什么没有拦截效果呢?aop配置文件:<?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:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://www.springframework.org/schema/aop 
      http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="permissionCheckAdvice"
    class="com.dybx.aop.PermissionCheckAdvice">
    </bean> <aop:aspectj-autoproxy proxy-target-class="true" /></beans>permissionCheckAdvice的代码:@Aspect
    public class PermissionCheckAdvice {
    // @Before("execution(* com.dybx.iservice.IBidService.*(..))")
    @Around("execution(*  com.dybx.web.BidController.*(..))")
    public Object invoke(ProceedingJoinPoint jointPoint) throws Throwable {
    System.out.println("method starts..."
    + jointPoint.getSignature().getDeclaringTypeName() + "."
    + jointPoint.getSignature().getName());
    System.out.println("..." + jointPoint.getArgs().length);
    System.out.println("..." + jointPoint.getArgs()[1]); Object retVal = jointPoint.proceed(); System.out.println("method ends..."
    + jointPoint.getSignature().getDeclaringTypeName() + "."
    + jointPoint.getSignature().getName());
    System.out.println("method ends..." + retVal);
    return retVal;
    }}
    @Around("execution(*  com.dybx.web.BidController.*(..))")中的BidController是一个控制器类,为什么不起效果呢?