Reputation: 1362
I have a class annotated with an org.mapstruct.Mapper
and attempting to use an org.springframework.cache.annotation.Cacheable
annotation on a method. That method is also annotated with org.mapstruct.Named
.
The @Cacheable
annotation is being ignored.
Is it possible to use @Cacheble
on a Mapstruct @Mapper
method?
Upvotes: 0
Views: 623
Reputation: 56
I don't think that this is possible cause it seems that the mapstruct processor is filtering that annotation out. But you can inject a bean and cache the method of the bean like:
@Mapper(componentModel="spring")
public abstract class Mapper {
@Autowired
protected Bean bean;
@Named("someNamedMethod")
public Object doSomething() {
return bean.doSomeMagic()
}
@Component
public class Bean {
@Cacheable(your params)
public Object doSomething() {
your code... }
}
Upvotes: 1