To take advantage of Spring Cloud Bus, we use the Redis starter spring-cloud-starter-bus-redis as the bus channel.
It is possible to disable the bus via spring.cloud.bus.enabled=false when running tests or a local no-deps profile for example. However, it does not seem possible to disable RedisAutoConfiguration.
Given that a Redis instance is not running, the app will startup without error but the /health endpoint will complain about Redis being Down. This causes issues if you want to selectively enable service discovery for instance. I.e. you want service discovery on but the bus off etc.
There should be a way to disable RedisAutoConfiguration via something like spring.redis.enabled=false or something like that.
There are various way to disable the RedisAutoConfiguration, there is an exclude attribute on the @SpringBootApplication and a spring.autoconfigure.exclude property if you can't use that. We've been asked this several times and rejected the feature so far as spring.redis.enabled is just a syntaxic sugar on top of that and we're not keen on having several ways of doing the same thing.
Ok, spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration works. Thanks
I did as suggested @donovanmuller - that gets me past the cachemanager issue but now I am get NoSuchBeanDefinitionException redisTemplate - this is because redisReferenceResolver is trying to look that up
So, it's still looking for Redis.
@chb0github Unless my memory is failing me, a bean named redisReferenceResolver isn't part of Spring Boot
Looking at my debugger right now, the bean it's trying to hydrate is:
org.springframework.data.redis.core.convert.ReferenceResolverImpl which is coming from spring-data-redis:1.8.0.RELEASE which is coming from this dependency: compile('org.springframework.boot:spring-boot-starter-data-redis') . I admit, the bean name is a bit misleading. The type it actually resolves to is not
The only other reference to redis is in our hibernate support.
As far as I can tell, there's nothing in Spring Data Redis that creates a ReferenceResolverImpl bean. Without any evidence to the contrary I can only assume that the redisReferenceResolver bean definition is in your own configuration. If that's not the case, please create a sample that reproduces the problem and open a new issue against the appropriate project.
@chb0github Exclude RedisRepositoriesAutoConfiguration.class to resolve "no such bean redisTemplate" problem
@Stamp1d0 will give that a try. Thanks
good
Exclude original RedisAutoConfiguration
@Configuration
@EnableAutoConfiguration(exclude={RedisAutoConfiguration.class})
public class MyConfiguration {
}
Add customized configuration
@Configuration
@ConditionalOnProperty(prefix = "spring.redis", name = "enabled")
@Import(RedisAutoConfiguration.class)
public class CustomizedRedisAutoConfiguration {
}
And now you can using spring.redis.enabled property in application.yml.
Most helpful comment
Ok,
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationworks. Thanks