common utility aspects to use when creating systems with [spring-aop]
Questions tagged [spring-aspects]
129 questions
2
votes
0 answers
Not sure why Spring aspects aren't triggering
So I started digging into Spring AOP, and tried to create some basic aspect with annotations but it doesn't seem to trigger for some reason.
This is my aspect:
@Component
@Aspect
public class TestScribe {
private Logger logger;
@Autowired
…

Ceiling Gecko
- 3,104
- 2
- 24
- 33
2
votes
0 answers
Gradle AspectJ plugin issue
I am facing a major issue with my Spring application since I migrated from Maven to Gradle: aspectj no longer works.
For instance classes annotated with @Configurable (which rely on aspectj) don't get their dependencies injected.
In order to replace…

balteo
- 23,602
- 63
- 219
- 412
1
vote
1 answer
Spring SPEL error: SpelEvaluationException: EL1057E: No bean resolver registered in the context to resolve access to bean 'validatorService'
When doing a POC, we use a custom annotation with a SPEL expression. The SPEL expression contains a reference to a bean method:
@CheckEntity(keyPath = "@validatorService.isColorRed(#color)")
The custom annotation is integrated with with AOP…

tm1701
- 7,307
- 17
- 79
- 168
1
vote
1 answer
Decorate or Intercept Spring @Autowired Bean
I am upgrading old Java EE application to Spring based solution. In the old applications there were custom annotations to create proxy inject proxy bean and intercept the method invocation [Interceptor classes implements MethodInterceptor) or…

Debopam
- 3,198
- 6
- 41
- 72
1
vote
2 answers
HttpServletRequest throws error when used within Aspect
I have a method which has an aspect. When I try to @Autowire HttpServletRequest, and use request.getHeader(something), I get this error -
No thread-bound request found: Are you referring to request attributes outside of an actual web request, or…
1
vote
0 answers
How to pass custom spring aspect annotation to advice
I've created a custom aspect annotation and passed it to the around advice but not able to read the values of the annotation. I'm not sure how to pass annotation to the advice and read its values. This implementation throws below error,
Caused by:…

shantih.antony
- 21
- 4
1
vote
1 answer
Java Spring AOP:Making advice work for PostMappings that belong only to certain classes in a package
Hello i am trying to apply logging to my app by using aop.At this moment i can apply the advice on all the PostMapping methods from the application by using this pointcut.
…

helloApp
- 449
- 1
- 4
- 21
1
vote
1 answer
Aspect annotation for class
I have a custom annotation, that is handled with AOP in Spring boot. It works perfect when I put it above a method, but when I put it above class I am not able to extract its value :(
Annotation
@Target({ElementType.METHOD,…

stefan.stt
- 2,357
- 5
- 24
- 47
1
vote
0 answers
Spring AOP : Create a poincut for a method in class which extend abstract class
I have an abstract class which are implementing some basic interface.
(attack method is not inherited from basic interface)
public abstract class AbstractClass implements BasicInterface {
public void attack(String attackerId, float…

Krzysztof Antczak
- 11
- 2
1
vote
0 answers
Get pathVariable in Aspect - Spring boot
I want implement an annotation in spring boot. It's required to get path variable and use in annotation.
@PostMapping("/v1/{id}")
@HasZone(id = "#id")
@ResponseStatus(HttpStatus.NO_CONTENT)
fun createCompany( @PathVariable id: String) {
…

mgh
- 921
- 3
- 9
- 37
1
vote
2 answers
Can pointcut expressions match generic parameter in Java methods?
My problem is that I my pointcut expression doesn't seem to match a method call and therefore is not executed. I suspect it has to do with generics in the parameter list.
The method I am trying to match has the following signature (actual names…

mymirs
- 11
- 1
1
vote
1 answer
Spring aspect how to update a common field across multiple objects
I am writing a Spring aspect and looking for a way to update a field on the returning object
My Dto's
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class BaseDto{
LocalDateTime…

JDev
- 1,662
- 4
- 25
- 55
1
vote
1 answer
Could not @Autowire implementation class, proxy mix-up
I am using Spring-boot to create a multi-module Maven application. I have the service layer in one module, the web layer in another. I can't start the application, having the following error:
The bean 'Service' could not be injected as a 'Service'…

Kristijan Rusu
- 567
- 4
- 14
1
vote
0 answers
Spring aspect around for @Service annotation is not working
I want to use aspect method depending on specific annotation. In my scenario when I mark up my business class with @Service annotation it is not working, but when I change it to component it starts to work.
Here is sample:
My Aspect class...
…

Bilgehan
- 1,135
- 1
- 14
- 41
1
vote
1 answer
@Async and @Transaction aspect order
Using Spring Boot 2.1.1.RELEASE / Spring Framework 5.1.4, I have an application with @Async and @Transactional annotations enabled through:
@EnableAsync(mode = AdviceMode.ASPECTJ)
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
When running…

Jasper Aarts
- 91
- 1
- 6