Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
Spring aspect support for repeatable annotation?

I have created a java8's repeatable annotation and want create an aspect before the method containing the annotation is invoked. This seems to work when method is annotated once but fails to invoke when I have repeatable annotation. I am using aspectjrt version 1.8.6. Looks like aspect doesn't support repeatable annotations. Any workaround?

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MultiCacheEvicts
{
    MultiCacheEvict[] value();
}

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(MultiCacheEvicts.class)
public @interface MultiCacheEvict
{
    String value();

    String[] keyPrefix() default "";
}

@Aspect
public class MultiCacheEvictAdvice
{
    @Before("@annotation(multiCacheEvict)")
    public void cacheEvict(JoinPoint joinPoint, MultiCacheEvict 
    multiCacheEvict)
    { 
       //never gets invoked when repeatable annotation present on the method
    }
}

/**This works**/
@MultiCacheEvict(value = "default", keyPrefix ={"messageAttributes"})
public void purgeCache(Set<Long> userIds)

/**This doesn't works, advice never gets invoked**/
@MultiCacheEvict(value = "default", keyPrefix ={"messageAttributes"})
@MultiCacheEvict(value = "entity", keyPrefix ={"tagAttributes"})
public void purgeCache(Set<Long> userIds)
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!