2016-10-04 51 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;