如何在春天中配置能

  介绍

本篇文章为大家展示了如何在春天中配置能,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

<强>能是复述的java客户端,春天将复述,连接池作为一个bean配置。

复述,连接池分为两种,一种是“<代码> redis.clients.jedis.ShardedJedisPool>

另一种是“<代码> redis.clients.jedis。JedisPool>

<强> maven导入相关包:

,, & lt; !——,复述,依赖包,——比;   & lt;才能dependency>   ,,& lt; groupId> redis.clients   ,,& lt; artifactId> jedis   ,,& lt; version> 2.9.0   & lt;才能/dependency>

ShardedJedisPool是复述,集群客户端的对象池,可以通过他来操作ShardedJedis、下面是ShardedJedisPool的xml配置,<代码> spring-jedis。xml :

& lt; ? xml  version=?.0“,编码=癠TF-8" ?比;   http://www.springframework.org/schema/beans" & lt; beans  xmlns=?;   ,,,xmlns: xsi=癶ttp://www.w3.org/2001/XMLSchema-instance"   ,,,xmlns:上下文=癶ttp://www.springframework.org/schema/context"   ,,,xsi: schemaLocation=? http://www.springframework.org/schema/beans   ,,,http://www.springframework.org/schema/beans/spring-beans.xsd   ,,,http://www.springframework.org/schema/context , http://www.springframework.org/schema/context/spring-context.xsd",在   & lt; !——,才能引入能的属性配置文件,——比;   & lt;才能!——如果你有多个数据源需要通过& lt;上下文:property-placeholder管理,且不愿意放在一个配置文件里,那么一定要加上ignore-unresolvable=" true"——比;   & lt;才能上下文:property-placeholder 位置=袄嗦肪?属性/redis.properties", ignore-unresolvable=皌rue",/比;   & lt;才能!——shardedJedisPool的相关配置——比;   & lt;才能bean  id=癹edisPoolConfig",类=皉edis.clients.jedis.JedisPoolConfig"比;   ,,,& lt; !——新版是maxTotal,旧版是maxActive——比;   ,,,& lt; property  name=癿axTotal"比;   ,,,,,& lt; value> $ {redis.pool.maxActive} & lt;/value>   ,,,& lt;/property>   ,,,& lt; property  name=癿axIdle"比;   ,,,,,& lt; value> $ {redis.pool.maxIdle} & lt;/value>   ,,,& lt;/property>   ,,,& lt; property  name=癶ttps://www.yisu.com/zixun/testOnBorrow",价值=" true "/>   <属性名=" testOnReturn " value=" true "/>            <列表>            列表         

<强>下面是单机环境下复述,连接池的配置:

& lt; ? xml  version=?.0“,编码=癠TF-8" ?比;   http://www.springframework.org/schema/beans" & lt; beans  xmlns=?;   ,,,xmlns: xsi=癶ttp://www.w3.org/2001/XMLSchema-instance"   ,,,xmlns:上下文=癶ttp://www.springframework.org/schema/context"   ,,,xsi: schemaLocation=? http://www.springframework.org/schema/beans   ,,,http://www.springframework.org/schema/beans/spring-beans.xsd   ,,,http://www.springframework.org/schema/context , http://www.springframework.org/schema/context/spring-context.xsd",在   & lt; !——,才能引入能的属性配置文件,——比;   & lt;才能!——如果你有多个数据源需要通过& lt;上下文:property-placeholder管理,且不愿意放在一个配置文件里,那么一定要加上ignore-unresolvable=" true"——比;   & lt;才能上下文:property-placeholder 位置=袄嗦肪?属性/redis.properties", ignore-unresolvable=皌rue",/比;   & lt;才能!——能连接池的相关配置——比;   & lt;才能bean  id=癹edisPoolConfig",类=皉edis.clients.jedis.JedisPoolConfig"比;   ,,,& lt; !——新版是maxTotal,旧版是maxActive——比;   ,,,& lt; property  name=癿axTotal"比;   ,,,,,& lt; value> $ {redis.pool.maxActive} & lt;/value>   ,,,& lt;/property>   ,,,& lt; property  name=癿axIdle"比;   ,,,,,& lt; value> $ {redis.pool.maxIdle} & lt;/value>   ,,,& lt;/property>   ,,,& lt; property  name=癶ttps://www.yisu.com/zixun/testOnBorrow",价值=" true "/>   <属性名=" testOnReturn " value=" true "/>      

如何在春天中配置能