Custom CacheInterceptor is being overridden by default Spring's CacheInterceptor Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How can I disable these log messages in JasperReports?Configure Spring Security to use custom UsernamePasswordAuthenticationFilterWRONG VERSION in log: INFO org.hibernate.cfg.EnvironmentSpring overriding primary bean with non-primary beanSpring Batch @Primary annotation overriding incorrect beanThe exact alternative to init-method (Java-based)Spring OAUTH: Override CheckTokenEndpoint 'check_token?token=' response mapSpring boot auto configuration overriding custom (elasticsearchTemplate) configurationspringboot project with multiple module and multiple main class -unit test failingConflict between spring data jpa and spring data DynamoDB

Moving a wrapfig vertically to encroach partially on a subsection title

Should a wizard buy fine inks every time he want to copy spells into his spellbook?

Does the Mueller report show a conspiracy between Russia and the Trump Campaign?

How to ask rejected full-time candidates to apply to teach individual courses?

Why is a lens darker than other ones when applying the same settings?

The test team as an enemy of development? And how can this be avoided?

Co-worker has annoying ringtone

Monty Hall Problem-Probability Paradox

How to force a browser when connecting to a specific domain to be https only using only the client machine?

Special flights

Why is it faster to reheat something than it is to cook it?

New Order #6: Easter Egg

Is there public access to the Meteor Crater in Arizona?

Why complex landing gears are used instead of simple,reliability and light weight muscle wire or shape memory alloys?

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

A proverb that is used to imply that you have unexpectedly faced a big problem

What are the main differences between Stargate SG-1 cuts?

Flight departed from the gate 5 min before scheduled departure time. Refund options

Differences to CCompactSize and CVarInt

What would you call this weird metallic apparatus that allows you to lift people?

"klopfte jemand" or "jemand klopfte"?

Tannaka duality for semisimple groups

What does it mean that physics no longer uses mechanical models to describe phenomena?



Custom CacheInterceptor is being overridden by default Spring's CacheInterceptor



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How can I disable these log messages in JasperReports?Configure Spring Security to use custom UsernamePasswordAuthenticationFilterWRONG VERSION in log: INFO org.hibernate.cfg.EnvironmentSpring overriding primary bean with non-primary beanSpring Batch @Primary annotation overriding incorrect beanThe exact alternative to init-method (Java-based)Spring OAUTH: Override CheckTokenEndpoint 'check_token?token=' response mapSpring boot auto configuration overriding custom (elasticsearchTemplate) configurationspringboot project with multiple module and multiple main class -unit test failingConflict between spring data jpa and spring data DynamoDB



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








4















I've implemented a custom CacheInterceptor which allows evicting the cache by wildcard:



public class CustomCacheInterceptor extends CacheInterceptor 

private static final Logger LOGGER = LoggerFactory.getLogger(CustomCacheInterceptor.class);

@Override
protected void doEvict(Cache cache, Object key)
try
// evict cache
catch (RuntimeException ex)
getErrorHandler().handleCacheEvictError(ex, cache, key);





Now I'm trying to make it working:



@Configuration
public class CustomProxyCachingConfiguration extends ProxyCachingConfiguration

private static final Logger LOGGER = LoggerFactory.getLogger(CustomProxyCachingConfiguration.class);

@Bean
public CacheInterceptor cacheInterceptor()
LOGGER.info("Creating custom cache interceptor");

CacheInterceptor interceptor = new CustomCacheInterceptor();
interceptor.setCacheOperationSources(cacheOperationSource());
if (this.cacheResolver != null)
interceptor.setCacheResolver(this.cacheResolver);
else if (this.cacheManager != null)
interceptor.setCacheManager(this.cacheManager);

if (this.keyGenerator != null)
interceptor.setKeyGenerator(this.keyGenerator);

if (this.errorHandler != null)
interceptor.setErrorHandler(this.errorHandler);

return interceptor;




The problem is that my CustomCacheInterceptor is being overridden by default one:



Overriding user-defined bean definition for bean 'cacheInterceptor' with a framework-generated bean definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=customProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/package/test/CustomProxyCachingConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cache.annotation.ProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]]


I've tried different ways to solve this problem:



1) Tried to exclude ProxyCachingConfiguration with @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) and provide own BeanFactoryCacheOperationSourceAdvisor - didn't help



2) Tried @Primary but it seems to be working only at injection time - not my case



3) Tried to choose different name of the bean - "customCacheInterceptor" - in this case my custom class is not being invoked



4) Tried to add @DependsOn("cacheOperationSource") which is located in ProxyCachinConfiguration to make Spring loading ProxyCachinConfiguration before my config - didn't help



The most strange thing is that sometimes my config wins during application start and everything works fine



How can I override default CacheInterceptor with my CustomCacheInterceptor?



Spring Boot Version - 2.0.0.RELEASE










share|improve this question
























  • Such low-level override of this feature is not really expected. The configuration is low-level and beans are configured with role infrastructure so they are not supposed to be post-processed either. Rather than hacking a core feature, please roll out your own annotation and create your own interceptor.

    – Stephane Nicoll
    Mar 22 at 15:31

















4















I've implemented a custom CacheInterceptor which allows evicting the cache by wildcard:



public class CustomCacheInterceptor extends CacheInterceptor 

private static final Logger LOGGER = LoggerFactory.getLogger(CustomCacheInterceptor.class);

@Override
protected void doEvict(Cache cache, Object key)
try
// evict cache
catch (RuntimeException ex)
getErrorHandler().handleCacheEvictError(ex, cache, key);





Now I'm trying to make it working:



@Configuration
public class CustomProxyCachingConfiguration extends ProxyCachingConfiguration

private static final Logger LOGGER = LoggerFactory.getLogger(CustomProxyCachingConfiguration.class);

@Bean
public CacheInterceptor cacheInterceptor()
LOGGER.info("Creating custom cache interceptor");

CacheInterceptor interceptor = new CustomCacheInterceptor();
interceptor.setCacheOperationSources(cacheOperationSource());
if (this.cacheResolver != null)
interceptor.setCacheResolver(this.cacheResolver);
else if (this.cacheManager != null)
interceptor.setCacheManager(this.cacheManager);

if (this.keyGenerator != null)
interceptor.setKeyGenerator(this.keyGenerator);

if (this.errorHandler != null)
interceptor.setErrorHandler(this.errorHandler);

return interceptor;




The problem is that my CustomCacheInterceptor is being overridden by default one:



Overriding user-defined bean definition for bean 'cacheInterceptor' with a framework-generated bean definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=customProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/package/test/CustomProxyCachingConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cache.annotation.ProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]]


I've tried different ways to solve this problem:



1) Tried to exclude ProxyCachingConfiguration with @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) and provide own BeanFactoryCacheOperationSourceAdvisor - didn't help



2) Tried @Primary but it seems to be working only at injection time - not my case



3) Tried to choose different name of the bean - "customCacheInterceptor" - in this case my custom class is not being invoked



4) Tried to add @DependsOn("cacheOperationSource") which is located in ProxyCachinConfiguration to make Spring loading ProxyCachinConfiguration before my config - didn't help



The most strange thing is that sometimes my config wins during application start and everything works fine



How can I override default CacheInterceptor with my CustomCacheInterceptor?



Spring Boot Version - 2.0.0.RELEASE










share|improve this question
























  • Such low-level override of this feature is not really expected. The configuration is low-level and beans are configured with role infrastructure so they are not supposed to be post-processed either. Rather than hacking a core feature, please roll out your own annotation and create your own interceptor.

    – Stephane Nicoll
    Mar 22 at 15:31













4












4








4


1






I've implemented a custom CacheInterceptor which allows evicting the cache by wildcard:



public class CustomCacheInterceptor extends CacheInterceptor 

private static final Logger LOGGER = LoggerFactory.getLogger(CustomCacheInterceptor.class);

@Override
protected void doEvict(Cache cache, Object key)
try
// evict cache
catch (RuntimeException ex)
getErrorHandler().handleCacheEvictError(ex, cache, key);





Now I'm trying to make it working:



@Configuration
public class CustomProxyCachingConfiguration extends ProxyCachingConfiguration

private static final Logger LOGGER = LoggerFactory.getLogger(CustomProxyCachingConfiguration.class);

@Bean
public CacheInterceptor cacheInterceptor()
LOGGER.info("Creating custom cache interceptor");

CacheInterceptor interceptor = new CustomCacheInterceptor();
interceptor.setCacheOperationSources(cacheOperationSource());
if (this.cacheResolver != null)
interceptor.setCacheResolver(this.cacheResolver);
else if (this.cacheManager != null)
interceptor.setCacheManager(this.cacheManager);

if (this.keyGenerator != null)
interceptor.setKeyGenerator(this.keyGenerator);

if (this.errorHandler != null)
interceptor.setErrorHandler(this.errorHandler);

return interceptor;




The problem is that my CustomCacheInterceptor is being overridden by default one:



Overriding user-defined bean definition for bean 'cacheInterceptor' with a framework-generated bean definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=customProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/package/test/CustomProxyCachingConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cache.annotation.ProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]]


I've tried different ways to solve this problem:



1) Tried to exclude ProxyCachingConfiguration with @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) and provide own BeanFactoryCacheOperationSourceAdvisor - didn't help



2) Tried @Primary but it seems to be working only at injection time - not my case



3) Tried to choose different name of the bean - "customCacheInterceptor" - in this case my custom class is not being invoked



4) Tried to add @DependsOn("cacheOperationSource") which is located in ProxyCachinConfiguration to make Spring loading ProxyCachinConfiguration before my config - didn't help



The most strange thing is that sometimes my config wins during application start and everything works fine



How can I override default CacheInterceptor with my CustomCacheInterceptor?



Spring Boot Version - 2.0.0.RELEASE










share|improve this question
















I've implemented a custom CacheInterceptor which allows evicting the cache by wildcard:



public class CustomCacheInterceptor extends CacheInterceptor 

private static final Logger LOGGER = LoggerFactory.getLogger(CustomCacheInterceptor.class);

@Override
protected void doEvict(Cache cache, Object key)
try
// evict cache
catch (RuntimeException ex)
getErrorHandler().handleCacheEvictError(ex, cache, key);





Now I'm trying to make it working:



@Configuration
public class CustomProxyCachingConfiguration extends ProxyCachingConfiguration

private static final Logger LOGGER = LoggerFactory.getLogger(CustomProxyCachingConfiguration.class);

@Bean
public CacheInterceptor cacheInterceptor()
LOGGER.info("Creating custom cache interceptor");

CacheInterceptor interceptor = new CustomCacheInterceptor();
interceptor.setCacheOperationSources(cacheOperationSource());
if (this.cacheResolver != null)
interceptor.setCacheResolver(this.cacheResolver);
else if (this.cacheManager != null)
interceptor.setCacheManager(this.cacheManager);

if (this.keyGenerator != null)
interceptor.setKeyGenerator(this.keyGenerator);

if (this.errorHandler != null)
interceptor.setErrorHandler(this.errorHandler);

return interceptor;




The problem is that my CustomCacheInterceptor is being overridden by default one:



Overriding user-defined bean definition for bean 'cacheInterceptor' with a framework-generated bean definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=customProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/package/test/CustomProxyCachingConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cache.annotation.ProxyCachingConfiguration; factoryMethodName=cacheInterceptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]]


I've tried different ways to solve this problem:



1) Tried to exclude ProxyCachingConfiguration with @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) and provide own BeanFactoryCacheOperationSourceAdvisor - didn't help



2) Tried @Primary but it seems to be working only at injection time - not my case



3) Tried to choose different name of the bean - "customCacheInterceptor" - in this case my custom class is not being invoked



4) Tried to add @DependsOn("cacheOperationSource") which is located in ProxyCachinConfiguration to make Spring loading ProxyCachinConfiguration before my config - didn't help



The most strange thing is that sometimes my config wins during application start and everything works fine



How can I override default CacheInterceptor with my CustomCacheInterceptor?



Spring Boot Version - 2.0.0.RELEASE







java spring spring-boot spring-cache






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 12:23







Mykola Yashchenko

















asked Mar 22 at 11:53









Mykola YashchenkoMykola Yashchenko

3,12432339




3,12432339












  • Such low-level override of this feature is not really expected. The configuration is low-level and beans are configured with role infrastructure so they are not supposed to be post-processed either. Rather than hacking a core feature, please roll out your own annotation and create your own interceptor.

    – Stephane Nicoll
    Mar 22 at 15:31

















  • Such low-level override of this feature is not really expected. The configuration is low-level and beans are configured with role infrastructure so they are not supposed to be post-processed either. Rather than hacking a core feature, please roll out your own annotation and create your own interceptor.

    – Stephane Nicoll
    Mar 22 at 15:31
















Such low-level override of this feature is not really expected. The configuration is low-level and beans are configured with role infrastructure so they are not supposed to be post-processed either. Rather than hacking a core feature, please roll out your own annotation and create your own interceptor.

– Stephane Nicoll
Mar 22 at 15:31





Such low-level override of this feature is not really expected. The configuration is low-level and beans are configured with role infrastructure so they are not supposed to be post-processed either. Rather than hacking a core feature, please roll out your own annotation and create your own interceptor.

– Stephane Nicoll
Mar 22 at 15:31












1 Answer
1






active

oldest

votes


















0














Spring bean overriding is messy and should be avoided. Last bean definition for given name creates the actual bean but there is no predictable order between definitions as it depends on multiple factors e.g. Groovy vs XML vs JavaConfig.



It would be safer to exclude the ProxyCachingConfiguration configuration class from your context @ComponentScan and redefine it yourself, providing both CacheInterceptor and BeanFactoryCacheOperationSourceAdvisor.



If your goal is to just replace the advice set in the default BeanFactoryCacheOperationSourceAdvisor bean you can define a new BeanPostProcessor bean and call setAdvice() during postProcessBeforeInitialization().






share|improve this answer























  • My goal is to make CustomCacheInterceptor working

    – Mykola Yashchenko
    Mar 22 at 12:23











  • Define "working", it would depend how you use it e.g. do you auto-wire it by type.

    – Karol Dowbecki
    Mar 22 at 12:24












  • Replace default CacheInterceptor with my own

    – Mykola Yashchenko
    Mar 22 at 12:24











  • I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

    – Mykola Yashchenko
    Mar 22 at 12:24











  • By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

    – Mykola Yashchenko
    Mar 22 at 12:28












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55299059%2fcustom-cacheinterceptor-is-being-overridden-by-default-springs-cacheinterceptor%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Spring bean overriding is messy and should be avoided. Last bean definition for given name creates the actual bean but there is no predictable order between definitions as it depends on multiple factors e.g. Groovy vs XML vs JavaConfig.



It would be safer to exclude the ProxyCachingConfiguration configuration class from your context @ComponentScan and redefine it yourself, providing both CacheInterceptor and BeanFactoryCacheOperationSourceAdvisor.



If your goal is to just replace the advice set in the default BeanFactoryCacheOperationSourceAdvisor bean you can define a new BeanPostProcessor bean and call setAdvice() during postProcessBeforeInitialization().






share|improve this answer























  • My goal is to make CustomCacheInterceptor working

    – Mykola Yashchenko
    Mar 22 at 12:23











  • Define "working", it would depend how you use it e.g. do you auto-wire it by type.

    – Karol Dowbecki
    Mar 22 at 12:24












  • Replace default CacheInterceptor with my own

    – Mykola Yashchenko
    Mar 22 at 12:24











  • I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

    – Mykola Yashchenko
    Mar 22 at 12:24











  • By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

    – Mykola Yashchenko
    Mar 22 at 12:28
















0














Spring bean overriding is messy and should be avoided. Last bean definition for given name creates the actual bean but there is no predictable order between definitions as it depends on multiple factors e.g. Groovy vs XML vs JavaConfig.



It would be safer to exclude the ProxyCachingConfiguration configuration class from your context @ComponentScan and redefine it yourself, providing both CacheInterceptor and BeanFactoryCacheOperationSourceAdvisor.



If your goal is to just replace the advice set in the default BeanFactoryCacheOperationSourceAdvisor bean you can define a new BeanPostProcessor bean and call setAdvice() during postProcessBeforeInitialization().






share|improve this answer























  • My goal is to make CustomCacheInterceptor working

    – Mykola Yashchenko
    Mar 22 at 12:23











  • Define "working", it would depend how you use it e.g. do you auto-wire it by type.

    – Karol Dowbecki
    Mar 22 at 12:24












  • Replace default CacheInterceptor with my own

    – Mykola Yashchenko
    Mar 22 at 12:24











  • I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

    – Mykola Yashchenko
    Mar 22 at 12:24











  • By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

    – Mykola Yashchenko
    Mar 22 at 12:28














0












0








0







Spring bean overriding is messy and should be avoided. Last bean definition for given name creates the actual bean but there is no predictable order between definitions as it depends on multiple factors e.g. Groovy vs XML vs JavaConfig.



It would be safer to exclude the ProxyCachingConfiguration configuration class from your context @ComponentScan and redefine it yourself, providing both CacheInterceptor and BeanFactoryCacheOperationSourceAdvisor.



If your goal is to just replace the advice set in the default BeanFactoryCacheOperationSourceAdvisor bean you can define a new BeanPostProcessor bean and call setAdvice() during postProcessBeforeInitialization().






share|improve this answer













Spring bean overriding is messy and should be avoided. Last bean definition for given name creates the actual bean but there is no predictable order between definitions as it depends on multiple factors e.g. Groovy vs XML vs JavaConfig.



It would be safer to exclude the ProxyCachingConfiguration configuration class from your context @ComponentScan and redefine it yourself, providing both CacheInterceptor and BeanFactoryCacheOperationSourceAdvisor.



If your goal is to just replace the advice set in the default BeanFactoryCacheOperationSourceAdvisor bean you can define a new BeanPostProcessor bean and call setAdvice() during postProcessBeforeInitialization().







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 12:13









Karol DowbeckiKarol Dowbecki

26.9k93860




26.9k93860












  • My goal is to make CustomCacheInterceptor working

    – Mykola Yashchenko
    Mar 22 at 12:23











  • Define "working", it would depend how you use it e.g. do you auto-wire it by type.

    – Karol Dowbecki
    Mar 22 at 12:24












  • Replace default CacheInterceptor with my own

    – Mykola Yashchenko
    Mar 22 at 12:24











  • I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

    – Mykola Yashchenko
    Mar 22 at 12:24











  • By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

    – Mykola Yashchenko
    Mar 22 at 12:28


















  • My goal is to make CustomCacheInterceptor working

    – Mykola Yashchenko
    Mar 22 at 12:23











  • Define "working", it would depend how you use it e.g. do you auto-wire it by type.

    – Karol Dowbecki
    Mar 22 at 12:24












  • Replace default CacheInterceptor with my own

    – Mykola Yashchenko
    Mar 22 at 12:24











  • I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

    – Mykola Yashchenko
    Mar 22 at 12:24











  • By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

    – Mykola Yashchenko
    Mar 22 at 12:28

















My goal is to make CustomCacheInterceptor working

– Mykola Yashchenko
Mar 22 at 12:23





My goal is to make CustomCacheInterceptor working

– Mykola Yashchenko
Mar 22 at 12:23













Define "working", it would depend how you use it e.g. do you auto-wire it by type.

– Karol Dowbecki
Mar 22 at 12:24






Define "working", it would depend how you use it e.g. do you auto-wire it by type.

– Karol Dowbecki
Mar 22 at 12:24














Replace default CacheInterceptor with my own

– Mykola Yashchenko
Mar 22 at 12:24





Replace default CacheInterceptor with my own

– Mykola Yashchenko
Mar 22 at 12:24













I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

– Mykola Yashchenko
Mar 22 at 12:24





I've tried to add @ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ProxyCachingConfiguration.class)) on my main class and it didn't help

– Mykola Yashchenko
Mar 22 at 12:24













By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

– Mykola Yashchenko
Mar 22 at 12:28






By default Spring invokes his own CacheInterceptor when proxying methods annotated with @Cacheable. I want to change the behaviour of this default CacheInterceptor - that's why I've created my own class

– Mykola Yashchenko
Mar 22 at 12:28




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55299059%2fcustom-cacheinterceptor-is-being-overridden-by-default-springs-cacheinterceptor%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현