Correct @EnableRedisHttpSession configuration with Redis Sentinel

安稳与你 提交于 2019-12-06 06:15:22

I finally found the solution. It was me being a developer that is not thinking forward enough...

At some point in the very distant past I got exceptions when booting one of the servers (The gateway, which is the important one when it comes to the session management), telling me that it cannot find jedisConnectionFactory bean. So I wrote one, hard-coded, in the main class... pointing to localhost at port 6379 :). No wonder sentinel configuration was ignored.

With that @Bean removed, everything is working perfectly.

The way I found it could be a good point of reference for others. At first, I noticed Spring ignores my entries in application.properties.

So, I wrote my own @Configuration class, with my own sentinelConfig @Bean and my own jedisConnectionFactory @Bean. Spring picked up my sentinelConfig, but totally ignored my jedisConnectionFactory (simple debug identified that issue).

So, I renamed the bean to something like customJedisConnectionFactory, and then I got an error message about having two beans implementing RedisConnectionFactory. From there it was quick to find the other @Bean in my source code.

Thanks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!