0
我有以下自定義註釋。切入點表達式不適用於自定義註釋
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Scheduled {
String cron() default "";
.....
實現類
@Named
public class JobDefination {
@Scheduled(concurrent = false, cron = "0 0/1 * * * ?")
public void removeHistory(){
.....
}
我已經由一個以上的切入點一個嘗試的看點
@Aspect
@Component
public class AspectImple {
@Before("@annotation(com.quartzConfiguration.Scheduled)")
public void beforeImplAnnotation() {
...
}
@Before("execution(* com.job.defination.JobDefination.*()) && @annotation(com.quartzConfiguration.Scheduled)")
public void beforeImpl2() {
...
}
。但是當石英調用方法時AOP不工作。有人可以請幫忙。
兩個注意事項:Spring有一個'@ Scheduled'註解。這是定義,而不是定義。你的註釋對象是由spring管理的嗎? –
不,這個帶註釋的對象是我們自定義的實現 –
我的意思是「Spring是否控制對象的生命週期?它創建它嗎?」它需要爲它建立一個代理。 –