springBoot启动时noauth authentication required
时间: 2023-12-01 20:39:18 浏览: 168
spring boot 实现用户登录认证
在Spring Boot中配置Redis密码时,需要在application.properties中添加配置:spring.redis.password=yourpassword。但是有时候这个配置在JedisConnectionFactory中没有被加载进去,导致启动时出现“noauth authentication required”错误。解决方法如下:
1. 在application.properties中添加以下配置:spring.redis.host=localhost spring.redis.port=6379 spring.redis.password=yourpassword spring.redis.database=0
2. 在RedisConfig中添加以下配置:
@Configuration public class RedisConfig { @Bean public JedisConnectionFactory jedisConnectionFactory() { RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); redisStandaloneConfiguration.setHostName("localhost"); redisStandaloneConfiguration.setPort(6379); redisStandaloneConfiguration.setPassword(RedisPassword.of("yourpassword")); JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder(); jedisClientConfiguration.connectTimeout(Duration.ofSeconds(60)); return new JedisConnectionFactory(redisStandaloneConfiguration, jedisClientConfiguration.build()); } }
这样就可以解决“noauth authentication required”错误了。
阅读全文