【问题标题】:spring AOP with ProxyFactoryBean not working带有ProxyFactoryBean的spring AOP不起作用
【发布时间】:2016-10-04 18:46:02
【问题描述】:

请找到下面的类结构,并帮助找到这里缺少的任何东西。 无法获取之前方法中提到的SOP。

public class HijackBeforeMethod implements MethodBeforeAdvice {
@Override
public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
    System.out.println("BEFORE METHOD CALL : additional concern before actual logic");
    System.out.println("Method : " + arg0);

}
}

主类如下

@RestController
public class A {

 @Autowired
 Dao b;
 ...
 b.print(); //This should call the before method
}

道类如下

Public class DaoImpl implements Dao{
 @Autowired
 Datasource ds
 public void print(){
 .....
 }
}

rest-servlet.xml 上下文文件条目如下

 <bean id="hijackBeforeMethodBean" class="com.scb.cadm.aop.HijackBeforeMethod" />
  <bean id="b" class="DaoImpl"></bean>
  <bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">/>
     <property name="target" ref="b"></property>
     <property name="interceptorNames">
         <list>
            <value>hijackBeforeMethodBean</value>
         </list>
     </property>
 </bean>

【问题讨论】:

    标签: java spring-mvc aop


    【解决方案1】:

    我发现了问题.. 代替 @自动连线 刀b; 我使用了代理 bean @自动连线 道代理;

    【讨论】:

      猜你喜欢
      • 2022-01-23
      • 1970-01-01
      • 2018-10-27
      • 2014-11-17
      • 1970-01-01
      • 1970-01-01
      • 2018-06-13
      • 2012-11-05
      • 1970-01-01
      相关资源
      最近更新 更多