亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

spring-redis文件有問題。

https://img1.sycdn.imooc.com//5d42aa2f0001269f08180244.jpg

報錯:NOAUTH Authentication required,

解決:我在redis配置文件中,配有

requirepass?mypassword

如果我注釋掉,也能解決問題,但是又不想注釋,那就修改spring-redis.xml文件吧,

最初一版:

<bean?class="redis.clients.jedis.JedisPool"?id="jedisPool">
????<constructor-arg?name="poolConfig"?ref="jedisPoolConfig"/>
????<constructor-arg?name="host"?value="127.0.0.1"/>
????<constructor-arg?name="port"?value="6389"/>
??<!--??<constructor-arg?name="timeout"?value="60000"/>
????<constructor-arg?name="password"?value="mypassword"/>-->
</bean>

啟動報錯上面的錯誤。

修改版:

<bean?class="redis.clients.jedis.JedisPool"?id="jedisPool">
????<constructor-arg?name="poolConfig"?ref="jedisPoolConfig"/>
????<constructor-arg?name="host"?value="127.0.0.1"/>
????<constructor-arg?name="port"?value="6389"/>
??<!--??<constructor-arg?name="timeout"?value="60000"/>-->
????<constructor-arg?name="password"?value="mypassword"/>
</bean>

啟動時報錯。

一直嘗試,又看了JedisPool源碼,猜測是不是和入參順序有關

最終一版,就成功了;

<bean?class="redis.clients.jedis.JedisPool"?id="jedisPool">
????<constructor-arg?name="poolConfig"?ref="jedisPoolConfig"/>
????<constructor-arg?name="host"?value="127.0.0.1"/>
????<constructor-arg?name="port"?value="6389"/>
?????<constructor-arg?name="timeout"?value="60000"/>
????<constructor-arg?name="password"?value="mypassword"/>
</bean>


正在回答

2 回答

給力吖


0 回復 有任何疑惑可以回復我~

與順序沒關系,通過字段名稱映射的,你可以將配置信息直接配置到properties文件中,然后直接讓Spring加載進來即可

0 回復 有任何疑惑可以回復我~
#1

頑皮地牛

不好意思,看錯了,你是構造方法,不是設置屬性。是的,與順序有關系,要按照順序傳入
2019-08-01 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

spring-redis文件有問題。

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號