问答详情
源自:5-1 04-Jedis的入门

提示NOAUTH Authentication required?

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

提问者:玄鉴 2017-06-01 17:46

个回答

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

    jedis.auth("密码");

  • 玄鉴
    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