您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> spring boot 配置redis 报错 NOAUTH Authentication required

spring boot 配置redis 报错 NOAUTH Authentication required

来源:网络整理     时间:2016/9/2 0:19:39     关键词:

关于网友提出的“ spring boot 配置redis 报错 NOAUTH Authentication required”问题疑问,本网通过在网上对“ spring boot 配置redis 报错 NOAUTH Authentication required”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: spring boot 配置redis 报错 NOAUTH Authentication required
描述:

spring bootredisspring

spring boot 配置redis报错NOAUTH Authentication required
配置文件application.properties
# REDIS (RedisProperties)
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
spring.redis.database=0
# Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=127.0.0.1
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=foobared
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-active=8
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-wait=-1
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.max-idle=8
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.min-idle=0
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=0
pom.xml

org.springframework.boot
spring-boot-starter-parent
1.3.2.RELEASE
 


UTF-8
1.7



org.springframework.boot
spring-boot-starter


org.springframework.boot
spring-boot-starter-test
test


org.springframework.boot
spring-boot-starter-redis


测试类
import com.didispace.domain.User;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private RedisTemplate redisTemplate;
@Test
public void test() throws Exception {
// 保存字符串
stringRedisTemplate.opsForValue().set("aaa", "111");
Assert.assertEquals("111", stringRedisTemplate.opsForValue().get("aaa"));
// 保存对象
// User user = new User("超人", 20);
// redisTemplate.opsForValue().set(user.getUsername(), user);
//
// user = new User("蝙蝠侠", 30);
// redisTemplate.opsForValue().set(user.getUsername(), user);
//
// user = new User("蜘蛛侠", 40);
// redisTemplate.opsForValue().set(user.getUsername(), user);
//
// Assert.assertEquals(20, redisTemplate.opsForValue().get("超人").getAge().longValue());
// Assert.assertEquals(30, redisTemplate.opsForValue().get("蝙蝠侠").getAge().longValue());
// Assert.assertEquals(40, redisTemplate.opsForValue().get("蜘蛛侠").getAge().longValue());
}
}
debug发现RedisTemplate对象中的信息不是我配置的内容,我配置的是127.0.0.1端口但是读取到的是localhost,我配置了秘密但是读取到密码是null
 spring boot 配置redis 报错 NOAUTH Authentication required spring boot 配置redis 报错 NOAUTH Authentication required
以上介绍了“ spring boot 配置redis 报错 NOAUTH Authentication required”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3711934.html

相关图片

相关文章