您的位置:首页 > 财经 > 金融 > 佛山市seo推广哪家好_重庆市公路建设信息网官网_百度权重查询爱站网_西安做网站的公司

佛山市seo推广哪家好_重庆市公路建设信息网官网_百度权重查询爱站网_西安做网站的公司

2025/3/23 8:21:26 来源:https://blog.csdn.net/bailichun19901111/article/details/146425923  浏览:    关键词:佛山市seo推广哪家好_重庆市公路建设信息网官网_百度权重查询爱站网_西安做网站的公司
佛山市seo推广哪家好_重庆市公路建设信息网官网_百度权重查询爱站网_西安做网站的公司

报错信息:

io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.

Redis密码配置确认无误,但是只要使用Redis存储就报这个异常。很可能是因为配置的spring.redis.password没有被读取到。



基本依赖:

implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

基本设置(application.properties):

spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=your_password
spring.redis.database=0
spring.redis.timeout=3000


解决方法:

@Configuration
public class RedisConfig {@Value("${spring.redis.password}")private String redisPassword;@Value("${spring.redis.host}")private String redisHost;@Value("${spring.redis.port}")private int redisPort;/*** 解决redis认证报错问题:io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.** @return*/@Beanpublic LettuceConnectionFactory redisConnectionFactory() {return new LettuceConnectionFactory(new RedisStandaloneConfiguration(redisHost, redisPort) {{setPassword(RedisPassword.of(redisPassword));}});}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com