当前位置: 首页 > news >正文

邯郸做移动网站费用软文是什么样子的

邯郸做移动网站费用,软文是什么样子的,深圳个性化建网站服务商,c 用mysql做的网站redis报错汇总 在单元测试时,使用jedis通常遇到如下报错: 实例化报错->连接报错->权限报错。此报错是有顺序的:例如,若连接报错,说明实例化完成,即配置文件配对了。若权限报错,说明连接…

redis报错汇总

在单元测试时,使用jedis通常遇到如下报错:

实例化报错->连接报错->权限报错。此报错是有顺序的:例如,若连接报错,说明实例化完成,即配置文件配对了。若权限报错,说明连接通了,但密码错误。若实例化就报错,说明配置文件配错了,没法启动redis客户端,更别说去连接了。

具体报错如下:

1.实例化报错

Failed to load ApplicationContext.
Error creating bean with name 'jedisPool' defined in class path resource [applicationContext-redis.xml]: 
Unsatisfied dependency expressed through constructor parameter 0: 
Ambiguous argument values for parameter of type [org.apache.commons.pool2.impl.GenericObjectPoolConfig] 
- did you specify the correct bean references as arguments?

 出现此错误,通常是配置文件出错:配置JedisPool出错。


2.连接报错

connect timed out

出现此错误,通常是网络问题。一般在公司里,内网外网防火墙等各种网络情况。记得切换网络。


3.权限报错

        1.没有配置password(如果需要密码)

NOAUTH Authentication required.

 出现此错误,说明配置文件没有配password。

        2.密码错误

ERR invalid password

出现此错误,说明密码错了。

需要注意:

如下配置是错误的,这也是导致实例化报错的主要原因。

    <bean id="jedisPool" class="redis.clients.jedis.JedisPool"><constructor-arg name="host" value="192.168.100.12"/><constructor-arg name="port" value="6379"/><constructor-arg name="password" value="xxx"/></bean>

 查看jedis源码,发现设置密码,JedisPool的构造参数如下:

    public JedisPool(GenericObjectPoolConfig poolConfig, String host, int port, int timeout, String password) {this(poolConfig, host, port, timeout, password, 0, (String)null);}

即,需要配置如下参数:

    <bean class="redis.clients.jedis.JedisPool" id="jedisPool" ><constructor-arg name="host" value="192.168.100.12"></constructor-arg><constructor-arg name="port" value="6379"></constructor-arg><constructor-arg name="password" value="xxx"></constructor-arg><constructor-arg name="timeout" value="3000"></constructor-arg><constructor-arg name="poolConfig" ref="jedisPoolConfig"></constructor-arg></bean><bean class="redis.clients.jedis.JedisPoolConfig" id="jedisPoolConfig"><property name="maxIdle" value="300" /><property name="maxTotal" value="1000" /><property name="maxWaitMillis" value="1000" /><property name="testOnBorrow" value="false" /><property name="blockWhenExhausted" value="false" /></bean>

如果redis没有设置密码的话,配置就可以很简单:

    <bean id="jedisPool" class="redis.clients.jedis.JedisPool"><constructor-arg name="host" value="192.168.100.12"/><constructor-arg name="port" value="6379"/></bean>

因为JedisPool提供了只需要ip地址和端口的构造参数,如下:

    public JedisPool(String host, int port) {this(new GenericObjectPoolConfig(), host, port, 2000, (String)null, 0, (String)null);}

补充:

bean的xml文件格式:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 这中间写bean -->
<!--    <bean id="jedisPool" class="redis.clients.jedis.JedisPool">-->
<!--        <constructor-arg name="host" value="192.168.100.12"/>-->
<!--        <constructor-arg name="port" value="6379"/>-->
<!--    </bean>--></beans>

单元测试类:

@RunWith(SpringRunner.class)//spring整合JUnit4
@ContextConfiguration(locations={"classpath:applicationContext-redis.xml"})//加载spring配置文件
public class BaseRedisTest {
}

 

==================分割线====================

文章到此已经结束,以下是紫薯布丁

Failed to load ApplicationContext.
Error creating bean with name 'jedisPool' defined in class path resource [applicationContext-redis.xml]: 
Unsatisfied dependency expressed through constructor parameter 0: 
Ambiguous argument values for parameter of type [org.apache.commons.pool2.impl.GenericObjectPoolConfig] 
- did you specify the correct bean references as arguments?

connect timed out

NOAUTH Authentication required.

ERR invalid password

    <bean id="jedisPool" class="redis.clients.jedis.JedisPool">
        <constructor-arg name="host" value="192.168.100.12"/>
        <constructor-arg name="port" value="6379"/>
        <constructor-arg name="password" value="xxx"/>
    </bean>

    public JedisPool(GenericObjectPoolConfig poolConfig, String host, int port, int timeout, String password) {
        this(poolConfig, host, port, timeout, password, 0, (String)null);
    }

    <bean class="redis.clients.jedis.JedisPool" id="jedisPool" >
        <constructor-arg name="host" value="192.168.100.12"></constructor-arg>
        <constructor-arg name="port" value="6379"></constructor-arg>
        <constructor-arg name="password" value="xxx"></constructor-arg>
        <constructor-arg name="timeout" value="3000"></constructor-arg>
        <constructor-arg name="poolConfig" ref="jedisPoolConfig"></constructor-arg>
    </bean>
    <bean class="redis.clients.jedis.JedisPoolConfig" id="jedisPoolConfig">
        <property name="maxIdle" value="300" />
        <property name="maxTotal" value="1000" />
        <property name="maxWaitMillis" value="1000" />
        <property name="testOnBorrow" value="false" />
        <property name="blockWhenExhausted" value="false" />
    </bean>

    <bean id="jedisPool" class="redis.clients.jedis.JedisPool">
        <constructor-arg name="host" value="192.168.100.12"/>
        <constructor-arg name="port" value="6379"/>
    </bean>

    public JedisPool(String host, int port) {
        this(new GenericObjectPoolConfig(), host, port, 2000, (String)null, 0, (String)null);
    }
 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

<!-- 这中间写bean -->
<!--    <bean id="jedisPool" class="redis.clients.jedis.JedisPool">-->
<!--        <constructor-arg name="host" value="192.168.100.12"/>-->
<!--        <constructor-arg name="port" value="6379"/>-->
<!--    </bean>-->

</beans>

@RunWith(SpringRunner.class)//spring整合JUnit4
@ContextConfiguration(locations={"classpath:applicationContext-redis.xml"})//加载spring配置文件
public class BaseRedisTest {
}

http://www.qdjiajiao.com/news/6944.html

相关文章:

  • 上海网站建设的价百度广告大全
  • 怎么用云主机做网站免费网站制作app
  • 怎么免费做网站推广搜索引擎营销
  • 新手做网站的详细步骤seo工具
  • 免费net网站空间冯耀宗seo博客
  • 做网站要商标吗电子商务
  • 网站开发与运用个人主页网页设计
  • 怎样做金融网站百度网盘在线观看资源
  • 医院网站建设情况说明书百度关键词查询
  • 移动端网站开发教程上海培训机构排名
  • 网站开发公司简介条友网
  • 网站seo 优帮云关键词优化排名首页
  • 湘西建设监理协会网站搜狗收录提交
  • 织梦网站图片怎么做滚动图片宁波seo排名费用
  • 手机怎么做网站服务器吗友链出售
  • 大连哪有做网站的搜索引擎排名规则
  • 可以在线做试卷的网站网站设计公司苏州
  • 网站弹窗怎么做南昌百度推广联系方式
  • 网站后台里有网页代码没网站设计与建设
  • 打车网站开发优秀营销案例分享
  • 怎么做新浪网站seo是什么味
  • 塘厦东莞网站建设百度百科优化排名
  • 顺庆区城乡规划建设局门户网站优化网站推广网站
  • 昆明做网站建设找谁在线工具
  • 登錄wordpress界面应用关键词优化
  • 建设银行山东 2015招聘网站2345网址导航官网官方电脑版下载
  • 广州沙河一起做网站的网址亚洲7号卫星电视
  • 做游戏视频网站要批证吗百度搜索排名服务
  • 网站开发的岗位地推项目对接平台
  • 网站建设服务的风险郴州网络推广公司排名