我在Spring中使用自定義註釋創建Bean。當我引入AOP時,Spring Class.getAnnotationsByType無法正常工作
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface CliCommand {
Slice slice();
}
運行時(啓動)期間我想加載所有具有此批註的類。
在這個過程中我打電話。
CliCommand[] cliAnnotations = myclass.getAnnotationsByType(CliCommand.class);
在我介紹AOP之前,它工作正常。
但是現在這返回NULL。
我的AOP看起來像這樣。
@Pointcut("within(com.companyx.cli..*)")
public void cliLayer() {
}
@Before("cliLayer()")
public void injectCLI(JoinPoint jp){
MDC.put(ConnectApplicationContext.LOG_LAYER_NAME, Layer.CLI);
}
我不知道爲什麼會發生這種情況。有沒有人見過這個。這與cgLib有關嗎?
我已經發現了一些註釋您的自定義註解。 – Richie