0
「aop:aspectj-autoproxy」和「mvc:annotation-driven」都存在於XML配置中。 這兩個類都被定義爲同一個XML中的一個bean。爲什麼我的建議/切入點根本無法運行?
本地/開發環境使用Spring 3.2.3.RELEASE和谷歌App Engine的1.8.1。
我的切入點不執行。
我的建議。在用@Aspect註解的類中聲明。
@Component
@Aspect
public class RequestLimiter {
private MemcacheService cache = MemcacheServiceFactory.getMemcacheService();
@Pointcut("within(@pcs.annotations.LimitRequests com.zdware.pcs.controllers.PingCollectorController)")
public void methodRequestLimited(){}
@Around("methodRequestLimited() && args(req,limitRequests)")
public Object requestGateWay(ProceedingJoinPoint jp, HttpServletRequest req,LimitRequests limitRequests) throws Throwable {
// do stuff
}
}
我用來在控制器層測試的方法。
@Controller
public class PingCollectorController {
@RequestMapping(value="/test")
@LimitRequests(requestTimeLimit = 1, functionName = "Test")
public String test(){
return "test"; // this will return me to a jsp that doesnt exist, but my advice is still not executing.
}
}
我沒有明確包含它作爲依賴關係,但我只是添加它,但仍然沒有:( – Zerkz
必須是AOP表達式的錯誤然後 – Keith
是的,我不知道我真的接近實施建議作爲控制器上的實際方法,只是通過反射傳遞註釋值作爲參數.... 可能是更好的性能也考慮到谷歌應用程序引擎更喜歡你硬編碼的東西而不是使用XML /掃描。 – Zerkz