项目搭建连接redis
来源:互联网 发布:软件详细设计模板 java 编辑:程序博客网 时间:2024/06/17 12:08
service-beans.xml的内容:
<?xml version="1.0" encoding="GB2312"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:util="http://www.springframework.org/schema/util"xmlns:aop="http://www.springframework.org/schema/aop"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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <context:component-scan base-package="com.hundsun"/><context:annotation-config /><!--定时任务 --> <import resource="compet-front-timer-task.xml" /><bean id="propertyConfigurerForProject2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="order" value="2" /> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="locations"> <list> <value>classpath:conf/server.properties</value> <value>classpath:conf/redis.properties</value> </list> </property> </bean><!-- 切面 --> <bean id="serviceInterceptor" class="com.hundsun.front.compet.aop.ServiceInterceptor"/><aop:config proxy-target-class="true"> <!-- ### 切点 ### --> <aop:pointcut id="businessService" expression="execution(* com.hundsun.compet.biz.service.impl.*.*(..))" /> <!-- Debug方法入参 ,返回值 -逻辑织入 --> <aop:aspect id="serviceAspect" ref="serviceInterceptor"> <aop:before pointcut-ref="businessService" method="doBeforeService"/> <!-- Debug Method output Object --> <aop:around pointcut-ref="businessService" method="doReturnValue"/> </aop:aspect> </aop:config> <!-- redis 操作 配置 --><bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"><property name="maxTotal" value="${redis.maxTotal}"></property><property name="maxIdle" value="${redis.maxIdle}"></property><property name="maxWaitMillis" value="${redis.maxWaitMillis}"></property><property name="minEvictableIdleTimeMillis" value="${redis.minEvictableIdleTimeMillis}"></property><property name="numTestsPerEvictionRun" value="${redis.numTestsPerEvictionRun}"></property><property name="timeBetweenEvictionRunsMillis" value="${redis.timeBetweenEvictionRunsMillis}"></property></bean><context:property-placeholder location="classpath*:conf/redis.properties"ignore-unresolvable="true" /><bean id="connectionFactory"class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"><property name="poolConfig" ref="jedisPoolConfig" /><property name="hostName" value="${redis.host}"></property><property name="port" value="${redis.port}" /><property name="password" value="${redis.password}" /><property name="timeout" value="${redis.timeout}" /></bean><bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"><property name="connectionFactory" ref="connectionFactory" /><property name="keySerializer"><beanclass="org.springframework.data.redis.serializer.StringRedisSerializer"></bean></property><property name="valueSerializer"><beanclass="org.springframework.data.redis.serializer.StringRedisSerializer"></bean></property></bean><bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"><property name="connectionFactory" ref="connectionFactory" /></bean><bean class="com.hundsun.front.init.cache.CacheConfig"/></beans>
使用的时候:
引入包:
import org.springframework.data.redis.core.StringRedisTemplate;
使用:
@Autowired
private StringRedisTemplate stringRedisTemplate;
StringRedisTemplate常用操作
参考:
http://blog.csdn.net/u011911084/article/details/53435172
阅读全文
0 0
- 项目搭建连接redis
- IDEA使用maven搭建java项目连接redis(图文)
- idea15搭建简单maven项目测试连接redis
- springmvc+redis项目搭建
- laravel项目连接redis
- Redis 集群搭建与连接
- Spring Boot+Redis项目搭建
- redis环境搭建及java连接使用
- redis集群搭建以及Yii1.1连接redis集群
- Redis整合Spring项目搭建实例指导
- jersey + spring + mybatis + redis项目搭建
- java redis简单测试项目搭建
- Maven+springMVC+mybatis+redis 项目搭建
- springmvc+mybatis+redis的maven项目搭建
- jfinal+redis+maven搭建web项目
- spring-java项目中连接redis数据库
- 项目中redis连接不上
- SpringMVC+Spring+mybatis+Redis项目从零开始--分布式项目结构搭建
- web通信之长连接,长轮询(long polling)
- SQL简明数据分析教程
- 洛谷1081/codevs1199 开车旅行 链表,倍增,模拟
- poj3867(2-sat)
- JVM垃圾收集策略
- 项目搭建连接redis
- Django中生成二维码
- 编写自己的一个ajax库。
- tensorflow学习(一):Reduction以及tesorflow数学操作函数查找地址
- GNSS接收机通道数
- C++下载指定Url网络地址上的文件-Windows Api
- Wannafly模拟赛3-F 监视任务(贪心+线段树区间更新)
- Python快速笔记
- FCM聚类算法