2016-10-04 117 views
0

請找到如下的類結構並幫助找到這裏缺少的任何東西。 無法獲取之前方法中提到的SOP。ProxyFactoryBean不能正常工作的彈簧AOP

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 
} 

在DAO類如下

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

其餘-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> 

回答

0

我發現問題.. 代替 @Autowired Dao b; 我使用代理bean @Autowired Dao proxy;