disable repositories of redis directly
spring.data.redis.repositories.enabled = false
this is a good thing done by Spring Boot's Autoconfigure package. There is a class called RedisRepositoriesAutoConfiguration that checks whether there is Jedis and @ EnableRedisRepositories, in the current classpath. If it exists, it will automatically enable this annotation for you (without parameters), regardless of whether your code is useful or not, so the entire classpath class will be swept in.
the solution is also very simple. RedisRepositoriesAutoConfiguration will determine whether the configuration item spring.data.redis.repositories.enable exists. If it does not exist, it will take effect if it does not exist, if it exists or if the value is true, as long as it is explicitly set to false. If you do not want to write configuration information and do not need to use RedisRepository (it does not affect that RedisTemplate), can deal with it by checking whether the Bean of RedisRepositoryFactoryBean exists. If it does not exist, then execute the AutoConfiguration, as long as you create a RedisRepositoryFactoryBean in the code, for example,
).
@Bean
public RedisRepositoryFactoryBean redisRepositoryFactoryBean() {
return null;
}
if this Bean exists (though it is null), it will not be executed
how do you write your repository?
is there an annotation? with @ Repository
did you add Redis's bag?
have you matched the relevant configurations of Redis?
have you solved it yet? I think this official document says that if you use jpa or mongo-specific comments, you can solve this problem. Although it doesn't affect it, it looks uncomfortable
.