spring-aop

Spring boot 2.0.2, interception of Cloud Stream annotations with Aop not working anymore

断了今生、忘了曾经 提交于 2021-02-19 10:00:33
问题 I tried to keep the title as explicit and simple as possible. Basically, I need to intercept the usage of Cloud stream's @Input and @Output annotations. This is needed to automatically add a specific ChannelInterceptor to each MessageChannel. (The behaviour in the preSend method will be slightly different whether the message has been produced or consumed). For example, if I declare this advice @Around("@annotation(org.springframework.cloud.stream.annotation.Input)") public Object

Spring boot 2.0.2, interception of Cloud Stream annotations with Aop not working anymore

你说的曾经没有我的故事 提交于 2021-02-19 09:58:33
问题 I tried to keep the title as explicit and simple as possible. Basically, I need to intercept the usage of Cloud stream's @Input and @Output annotations. This is needed to automatically add a specific ChannelInterceptor to each MessageChannel. (The behaviour in the preSend method will be slightly different whether the message has been produced or consumed). For example, if I declare this advice @Around("@annotation(org.springframework.cloud.stream.annotation.Input)") public Object

Spring annotation AOP called twice

自作多情 提交于 2021-02-18 12:57:17
问题 I annotate my spring boot controller some functions with a custom annotation for logging purpose. However, I find the before advice is executed twice for nested methods. Looking for some idea here. Please refer to the code snippets below. Controller @RequestMapping(value = "apply") @OperationMILog public ApplyHttpResponse apply(@RequestHeader final String custId, @RequestAttribute final String cardNo, @RequestBody final InstallmentApplyHttpRequest installApplyReq, @PathVariable final String

Spring's AspectJ-mode caching versus AspectJ-mode transactions

空扰寡人 提交于 2021-02-18 11:44:07
问题 My question relates to Spring's AspectJ mode and especially how to enable it for: Transaction management Caching 1) I noticed that in order to enable the AspectJ mode for transaction management, I only had to do the following: @Configuration @EnableTransactionManagement(mode = AdviceMode.ASPECTJ) 2) Whereas in order to use AspectJ mode for caching it seems one has to: -Put the following jar into Tomcat's lib directory: org.springframework:spring-instrument-tomcat -Add the following line in

Bean 'x' of type [TYPE] is not eligible for getting processed by all BeanPostProcessors

ぐ巨炮叔叔 提交于 2021-02-17 06:48:30
问题 I have a ResourceAspect class: //@Component @Aspect public class ResourceAspect { @Before("execution(public * *(..))") public void resourceAccessed() { System.out.println("Resource Accessed"); } } Here is my Application class: @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication springApplication = new SpringApplication(Application.class); springApplication.run(args); } } The dependencies that are being used inside the project are:

Two Modules exports the same package (Spring)

佐手、 提交于 2021-02-11 15:48:34
问题 I get this error when I try run my project. After many hours of search I found out why this happens, but I have no idea how to exclude one from exporting the package. java.lang.module.ResolutionException: Modules spring.aop and aopalliance export package org.aopalliance.intercept to module spring.beans It is my first time with Spring in general (I need JPA for CRUD I'm working now with Hibernate). I used Intellij IDEA's "Add Framework..." function in order to add Spring Data JPA. My Maven pom

Two Modules exports the same package (Spring)

倖福魔咒の 提交于 2021-02-11 15:46:43
问题 I get this error when I try run my project. After many hours of search I found out why this happens, but I have no idea how to exclude one from exporting the package. java.lang.module.ResolutionException: Modules spring.aop and aopalliance export package org.aopalliance.intercept to module spring.beans It is my first time with Spring in general (I need JPA for CRUD I'm working now with Hibernate). I used Intellij IDEA's "Add Framework..." function in order to add Spring Data JPA. My Maven pom

spring aop @target and @within throw IllegalAccessError

情到浓时终转凉″ 提交于 2021-02-11 13:58:19
问题 when run the application, it throws IllegalAccessError,Application run failed here is demo aop、service、annotation used,a simple annotation and @Before advice,also enable @EnableAspectJAutoProxy @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface MethodInterceptAnnotation { } @Component @Aspect public class MethodInterceptAop { @Before("@target(com.example.demo.aop.MethodInterceptAnnotation)") public void beforeCheck() { System.out.println(

Spring AOP not working when using as a compiled jar in a different project

依然范特西╮ 提交于 2021-02-07 20:52:21
问题 I have a working AOP (when using inside the project it is written in) but when I build this project (maven install), and use that JAR in another project, and try to use the @TimedLog annotation, nothing happens. I try to breakpoint into it, but it doesn't reach there. It looks like this: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface TimedLog { boolean shouldAttachMethodArgs() default false; boolean shouldAttachReturnValue() default false; String message()

When using spring aop:around, how can I get return type of the pointcut method?

一个人想着一个人 提交于 2021-02-07 05:37:45
问题 I have a requirement now, that is when using mybatis(especially those batch execute sql), check parameter first , if the parameter is null or empty , then just return, don't proceed and if the return type is List,eg. List<User> getByIds(List<Long> idList) return empty ArrayList, if the return type is void: void batchInsert(List<User>) return null. The purpose is to avoid this situation, eg. select * from user where id in () insert into user(name,email) values () but from joinPoint I can't get