提示NOAUTH Authentication required?

来源:5-1 04-Jedis的入门

玄鉴

2017-06-01 17:46

我的redis 有密码,提示NOAUTH Authentication required 配置文件中杀出密码,服务就无法启动了,密码改回来,服务才能启动。那么代码中如何设置密码的?

写回答 关注

2回答

  • 矮小篮板怪
    2017-06-01 22:32:37
    已采纳

    jedis.auth("密码");

    玄鉴

    太帅了,谢谢

    2017-06-02 16:53:31

    共 1 条回复 >

  • 玄鉴
    2017-06-02 17:31:31

    JedisPoolConfig config=new JedisPoolConfig();

    config.setMaxTotal(30);

    config.setMaxIdle(10);

    JedisPool jedisPool=new JedisPool(config, "127.0.0.1", 6329);

    Jedis jedis=null;

    jedis.auth("gdserver");

    try {

    jedisPool.getResource();

    jedis.set("name", "imooc");

    String aString= jedis.get("name");

    System.out.println(jedis.get("name"));

    } catch (Exception e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }finally

    {

    if (jedis!=null) {

    jedis.close();

    }

    if (jedisPool!=null) {

    jedisPool.close();

    Exception in thread "main" java.lang.NullPointerException


Redis入门

本课程为Redis和Jedis使用的入门级教程,对Redis有初步了解

107617 学习 · 164 问题

查看课程

相似问题