我执行queryAsdstock方法时,无法进入MethodCacheInterceptor中,麻烦大家帮我分析一下什么愿意,代码如下。
<bean id="methodCacheInterceptor"
class="com.travelsky.tdp.rc.ehcache.MethodCacheInterceptor">
<property name="cache">
<ref local="methodCache" />
</property>
</bean> <bean id="methodCachePointCut"
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref local="methodCacheInterceptor" />
</property>
<property name="patterns">
<list>
<value>.*queryAsdstock.*</value>
</list>
</property>
</bean> <bean id="EHCachePoxyBean"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.travelsky.tdp.rc.manager.Manager</value>
</property>
<property name="target">
<ref bean="managerTarget" />
</property>
<property name="interceptorNames">
<list>
<value>methodCachePointCut</value>
</list>
</property>
</bean>

解决方案 »

  1.   


    不是多了一个点号的问题,我直接修改成.*queryAsdstock 或者.* 都不行,好像拦截器没生效。
      

  2.   

    配置文件如下:
    <bean id="manager"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref local="transactionManager" />
    </property>
    <property name="target">
    <ref local="managerTarget" />
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="save*">
    PROPAGATION_REQUIRED,-BaseRuntimeException
    </prop>
    <prop key="add*">
    PROPAGATION_REQUIRED,-BaseRuntimeException
    </prop>
    <prop key="delete*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>而managerTarget 并没有注入到action中。
    action中直接获取的bean如下:
    Manager manager = (Manager) AppContext.getBean("manager");
      

  3.   

    <bean id="managerTarget"
    class="com.travelsky.tdp.rc.manager.ManagerImpl">
    <property name="processSheetLogic">
    <ref local="processSheetLogic" />
    </property>
    <property name="searchSheetLogic">
    <ref local="searchSheetLogic" />
    </property>
    <property name="auditSheetLogic">
    <ref local="auditSheetLogic" />
    </property>
    </bean>