zl程序教程

您现在的位置是:首页 >  后端

当前栏目

spring-java项目中连接redis数据库

2023-09-14 09:04:42 时间

最近由于项目需要,要从redis数据库中查询一些数据,还没有了解过redis,只好硬着头皮上阵,记录一下连接过程:


 ?xml version="1.0" encoding="UTF-8"? 

 beans xmlns:rabbit="http://www.springframework.org/schema/rabbit"

 xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 xmlns:context="http://www.springframework.org/schema/context"

 xsi:schemaLocation="

http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/rabbit

http://www.springframework.org/schema/rabbit/spring-rabbit-1.2.xsd" 

 !-- redis连接池的配置 -- 

 bean id="jedisPoolConfig" 

 property name="maxTotal" value="${redis.maxTotal}" / 

 property name="maxIdle" value="${redis.maxIdle}" / 

 property name="minIdle" value="${redis.minIdle}" / 

 property name="maxWaitMillis" value="${redis.maxWaitMillis}" / 

 property name="testOnBorrow" value="${redis.testOnBorrow}"/ 

 property name="testOnReturn" value="${redis.testOnReturn}"/ 

 /bean 

 !-- 工厂类配置 -- 

 bean id="jedisConnectionFactory"

 property name="password" value="${redis.password}"/ 

 property name="usePool" value="true"/ 

 property name="hostName" value="${redis.host}" / 

 property name="port" value="${redis.port}" / 

 property name="poolConfig" ref="jedisPoolConfig" / 

 /bean 

 /beans 

涂宗勋 认真生活,快乐工作,保持理想!https://blog.csdn.net/tuzongxun