本篇文章为大家展示了iBash4J部署时启动项目连接不上Redis无法从JedisPool中获取连接该怎么办,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
以下是配置文件
redis.host=192.168.158.128redis.port=6379redis.password=#最小空闲数redis.minIdle=2#最大空闲数redis.maxIdle=10#最大连接数redis.maxTotal=100#最大建立连接等待时间
redis.maxWaitMillis=8000#客户端超时时间单位是毫秒redis.timeout=120000#明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个redis.testOnBorrow=trueredis.expiration=600#redisclusterspring.redis.cluster.nodes=192.168.158.128:7001,192.168.158.128:7002,192.168.158.128:7003,192.168.158.128:7004,192.168.158.128:7005,192.168.158.128:7006spring.redis.cluster.max-redirects=3#rediscluster
<?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!-- jedis 配置-->
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig" ><!--最小空闲数-->
<property name="minIdle" value="${redis.minIdle}" /><!--最大空闲数-->
<property name="maxIdle" value="${redis.maxIdle}" /><!--最大连接数-->
<property name="maxTotal" value="${redis.maxTotal}" /><!--最大建立连接等待时间-->
<property name="maxWaitMillis" value="${redis.maxWaitMillis}" /><!--是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个-->
<property name="testOnBorrow" value="${redis.testOnBorrow}" /> </bean >
<bean id="jedisShardInfo" class="org.ibase4j.core.support.cache.jedis.JedisShardInfo"> <constructor-arg index="0" value="${redis.host}" /> <constructor-arg index="1" value="${redis.port}" type="int" /> <property name="password" value="${redis.password}" />
</bean>
<!-- redisCluster配置 --> <!-- <bean id="redisClusterConfiguration" class="org.springframework.data.redis.connection.RedisClusterConfiguration"> <constructor-arg name="propertySource"> <bean id="resourcePropertySource" class="org.springframework.core.io.support.ResourcePropertySource"> <constructor-arg name="name" value="redis.properties"/> <constructor-arg name="resource" value="classpath:config/system.properties"/> </bean> </constructor-arg> </bean> --> <!-- redis服务器中心 -->
<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:pool-config-ref="jedisPoolConfig" p:shard-info-ref="jedisShardInfo" p:timeout="${redis.timeout}" /><!-- 缓存序列化方式 --> <bean id="keySerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer" />
<bean id="valueSerializer" class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer" /><!-- 缓存 --> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="jedisConnectionFactory" /> <property name="keySerializer" ref="keySerializer" /> <property name="valueSerializer" ref="valueSerializer" /> <property name="hashKeySerializer" ref="keySerializer" /> <property name="hashValueSerializer" ref="valueSerializer" />
</bean>
<bean id="redisCacheManager" class="org.springframework.data.redis.cache.RedisCacheManager"> <constructor-arg index="0" ref="redisTemplate" /> <property name="defaultExpiration" value="10" />
</bean></beans>
上述内容就是iBash4J部署时启动项目连接不上Redis无法从JedisPool中获取连接该怎么办,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注天达云行业资讯频道。