JAVA记录-SpringMVC集成redis
1.redis.properties
#主机地址
redis.host=127.0.0.1
#端口号
redis.port=6379
#当池内没有返回对象时,最大等待时间毫秒数
redis.pool.maxWaitMillis=10000
#最大连接数
redis.pool.maxTotal=300
#最大能够保持idel空闲状态的对象数
redis.pool.maxIdle=20
#最小能够保持idel空闲状态的对象数
redis.pool.minIdle=5
#当调用borrow Object方法时,是否进行有效性检查
redis.pool.testOnBorrow=true
#当调用return Object方法时,是否进行有效性检查
redis.pool.testOnReturn=true
#超时
redis.timeout=15000
#是否用池
redis.usePool=true
#“空闲链接”检测线程,检测的周期,毫秒数。如果为负值,表示不运行“检测线程”。默认为-1.
redis.pool.timeBetweenEvictionRunsMillis=30000
#向调用者输出“链接”对象时,是否检测它的空闲超时;
redis.pool.testWhileIdle=true
# 对于“空闲链接”检测线程而言,每次检测的链接资源的个数。默认为3.
redis.pool.numTestsPerEvictionRun=50
2.spring-redis.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" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<context:component-scan base-package="com.net.xinfang" />
<context:property-placeholder location="classpath:redis.properties" ignore-unresolvable="true"/>
<!-- redis连接池的配置 -->
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="${redis.pool.maxTotal}" />
<property name="maxIdle" value="${redis.pool.maxIdle}" />
<property name="minIdle" value="${redis.pool.minIdle}" />
<property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}" />
<property name="testOnBorrow" value="${redis.pool.testOnBorrow}"/>
<property name="testOnReturn" value="${redis.pool.testOnReturn}"/>
</bean>
<!-- 工厂类配置 -->
<bean id="jedisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${redis.host}" />
<property name="port" value="${redis.port}" />
<property name="poolConfig" ref="jedisPoolConfig" />
<property name="timeout" value="${redis.timeout}"></property>
<property name="usePool" value="${redis.usePool}"></property>
</bean>
<bean id="jedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"></property>
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
</property>
</bean>
</beans>
JAVA记录-SpringMVC集成redis的更多相关文章
- SpringMVC 集成redis
一.下载导入jar 二.配置redis 1.创建redis.properties # Redis settings #redis.host=192.168.20.101 #redis.port= #r ...
- JAVA记录-SpringMVC国际化配置
1.搭建SpringMVC框架,不过多阐述 2.spring-mvc.xml加入以下配置: <!-- 国际化资源配置,资源文件绑定器--> <bean id="messag ...
- JAVA记录-SpringMVC+Mybatis几个核心注意的地方
1.DispatcherServlet -- 前置控制器 DispatcherServlet是一个Servlet,所以可以配置多个DispatcherServlet. DispatcherServ ...
- Java记录-SpringMVC整合Echarts画地图加散点图
1.搭建eclipse+JDK+Maven+SpringMVC+Spring+Mybatis后台架构,详细就不过多阐述了 2.下载百度eharts插件:http://echarts.baidu.com ...
- SpringMVC集成Redis
(1)添加pom依赖 <dependency> <groupId>org.springframework.data</groupId> <artifactId ...
- JAVA记录-SpringMVC scope属性的两种模式
singleton作用域:当把一个Bean定义设置为singleton作用域是,Spring IoC容器中只会存在一个共享的Bean实例,并且所有对Bean的请求,只要id与该Bean定义相匹配,则只 ...
- JAVA记录-redis缓存机制介绍(四)
Redis 数据备份与恢复 Redis SAVE 命令用于创建当前数据库的备份. 语法 redis Save 命令基本语法如下: redis 127.0.0.1:6379> SAVE 实例 re ...
- JAVA记录-redis缓存机制介绍(一)
1.redis介绍 Redis 简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Redis 与其他 key - value 缓存产品有以下三个特点: Re ...
- java 集成Redis 一主多从
1.测试代码如下: public static void main(String[] args) { Set<String> sentinels = new HashSet<Stri ...
随机推荐
- Comparison of Static Code Analysis Tools for Java
http://www.sw-engineering-candies.com/blog-1/comparison-of-findbugs-pmd-and-checkstyle https://stack ...
- 数据驱动测试之——CSV+TestNG
对于利用Webdriver做自动化的童鞋,对于如何将元素或者输入数据如何和编码分离都应该不会太陌生,本着一边学习一边分享的心态,大概总结了一下关于利用CSV.XML以及Excel来存放数据,然后在结合 ...
- node多文件处理方法
let events = require('events'); let fs = require('fs'); // 将readfile封装成一个方法 多文件处理 function fnreadFi ...
- Entity Framwork学习笔记
一.First Demo
- Linux下OSG的编译和安装以及遇到的问题
(第一段日常扯蛋,大家不要看)由于我们教研室所做的RTMapper要用到GDAL,所以就打算看osgearth的源码来熟悉下GDAL库的使用,同时也了解下osgearth中关于带有高程的图像拼接.然而 ...
- 判断Excel版本信息
可以通过获取application对应的Version属性获取当前打开的Excel的版本信息(Application.Version).
- 设计模式之抽象工厂模式(附带类似反射功能的实现/c++)
问题描述 假设我们要开发一款游戏, 当然为了吸引更多的人玩, 游戏难度不能太大(让大家都没有信心了,估计游戏也就没有前途了),但是也不能太简单(没有挑战性也不符合玩家的心理).于是我们就可以采用这样一 ...
- 好文章之——PHP系列(一)
注:最近实习的公司是一家做电商企业,后台主要是php开发,好久不怎么接触php的我看了几篇相关文章,提高下对它的认识与理解,发现里面的学习思路还是非常好的,当然也会重新拾一下基础知识啦! 其实自己心中 ...
- 软件工程_5th weeks
从周五开始经历了清明小长假,周六.周日和周一都处于假期状态,因此对于上篇博客的评论回复的很迟,而这周的工作做的也不多. 1.爆打小组 4.5日站立会议 时间:2016.4.5 15:00-15:34 ...
- codeforces278A
Circle Line CodeForces - 278A 郑州地铁的圆线有n个车站. 我们知道所有邻近站点之间的距离: d[1]是第1站和第2站之间的距离;d[2]是第2站和第3站之间的距离;… d ...