In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the example analysis of setting redis passwords for springboot integrated redis support. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
The recently used spring boot project needs to integrate the redis cluster, and you need to set the password when connecting to the redis. However, after setting the password, it is found that the boot integrated redis does not support setting the password (the same is true for the redis single node). Once you set the password, an error will be reported: Jedis does not support password protected Redis Cluster configurations
The version of boot I use is 1.4.x
Org.springframework.boot spring-boot-starter-parent 1.4.7.RELEASE
I took a look at the source code, which is shown in the figure:
Once it is found in the source code that you have set a password, directly throw an exception and get drunk.
Then I looked at the Redis-related version of the default integration, where the jedis version is 2.8.x, and the version of JedisCluster is 1.7.x, and none of the constructors in the corresponding version contain password parameters.
Solution 1: replace the versions of jedis and spring-data-redis
Before modification, the maven depends on the following
Org.springframework.boot spring-boot-starter-data-redis
The modified maven dependencies are as follows
Org.springframework.boot spring-boot-starter-data-redis redis.clients jedis org.springframework.data spring-data-redis redis.clients jedis 2.9.0 org.springframework.data spring-data-redis 1.8.0.RELEASE
Solution 2: upgrade boot version 1.5 or above
Org.springframework.boot spring-boot-starter-parent 1.5.2.RELEASE
In boot 1.5.x, the default jedis version is 2.9.x, and the default is 1.8.x, so you can use the redis password for verification.
Redis configuration example in application.properties file
# spring.redis.host = 140.143.23.94spring.redis.password = 123456#spring.redis.port = 637 connections timeout unit ms (milliseconds) spring.redis.timeout = 6000spring.redis.cluster.nodes = 12.2.3.14 123456#spring.redis.port 7001, 12.2.3.14, 7002, 12.2.3.14, 7003, 12.2.3.14, maximum idle connections in the connection pool The default value is also 8spring.redis.pool.max-idle = minimum idle connections in the connection pool, and the default value is 0spring.redis.pool.min-idle = idle. If the value is-1, there is no limit. If pool has allocated maxActive jedis instances, the status of pool is exhausted. Spring.redis.pool.max-active = 8 # maximum time to wait for available connections, in milliseconds. The default value is-1, which means that you will never time out. If more than waiting time, then directly throw spring.redis.pool.max-wait =-1 on "springboot integrated redis support to set redis password example analysis" this article will share here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.