Это в проекте Spring, где у меня есть настройка Aspect в другом модуле, от которого зависят другие модули. Я использую пользовательские аннотации. На некоторых методах работает нормально, а на других нет. Могу ли я получить совет о том, в чем проблема?
Этот класс Aspect происходит из модуля, и другие модули зависят от этого.
@Aspect
@Component
public class VirtualizeJsonAspect {
@Around("@annotation(virtualizeJson)")
public Object virtualizeJsonAround(ProceedingJoinPoint pjp, VirtualizeJson virtualizeJson) throws Throwable {
MethodSignature signature = (MethodSignature) pjp.getSignature();
Method method = signature.getMethod();
Class returnType = signature.getReturnType();
// ....... This is working fine
}
Следующие 3 класса в том же модуле, если применимо
Здесь работает, когда я пытаюсь использовать Aspect
Путь для справки -> com / domain / abc / service / helper / DataHelper.java
@Component
@PropertySource("classpath:something.properties")
public class DataHelper {
@VirtualizeJson(serviceNm = "ABC", virtualizedDataPath = "/url/some.json")
public SomeResponse getOffers(SomeRequest someRequest){
HttpEntity httpRequestEntity = createRequestEntity(request);
ResponseEntity<SomeResponse> httpResponseEntity;
SomeResponse someResponse = null;
// ......... Aspect works here. I do not get in here. Instead I land in the Aspect class as expected
}
}
файл конфигурации
Путь для ссылки -> com / domain / abc / service / config / AppConfig.java
@Configuration
@ComponentScan(basePackages = {{"com.domain.virtualize"})
@EnableAspectJAutoProxy
public class AppConfig extends WebMvcConfigurationSupport{
// some bean setups not rlevant to Aspect
}
Здесь не работает, когда я пытаюсь использовать Aspect
Путь для справки -> com / domain / abc / service / rules / CheckSomething.java
@Component
public class CheckSomething extends SomeRule {
@VirtualizeJson(serviceNm = "ABC", virtualizedDataPath = "/url/some.json")
public SomeResponse checkOffers(String someNumber){
int a = 1;
return null;
// I land inside this method which is incorrect. I shouldh have landed at the Aspect class instead
}
}
Аннотация
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface VirtualizeJson {
public String serviceNm();
public String virtualizedDataPath();
}