SSM redis数据源配置

<!-- redis配置开始 -->
	<!-- 配置JedisPoolConfig实例 --> 
	<bean id="redisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">  
		<property name="maxIdle" value="${redis.maxIdle}" />  
		<property name="maxTotal" value="${redis.maxActive}" />  
		<property name="maxWaitMillis" value="${redis.maxWait}" />  
		<property name="testOnBorrow" value="${redis.testOnBorrow}" />  
	</bean>  
	<!-- Spring-redis连接池管理工厂 --> 
	<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="password" value="${redis.pass}" />
		<property name="timeout" value="${redis.timeOut}" />
		<property name="database" value="${redis.dbIndex}" />
		<property name="poolConfig" ref="redisPoolConfig" />
	</bean> 
	<!-- 配置RedisTemplate -->
	<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
		<property name="connectionFactory" ref="jedisConnectionFactory"/>
		<property name="keySerializer">
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
		</property>
		<property name="hashKeySerializer">  
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>  
		</property>
		<property name="valueSerializer">
			<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>
		</property>
		<property name="hashValueSerializer">  
			<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>  
		</property>
	</bean>
	<!-- 配置SpringRedisTemplate -->
	<bean id="StringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
		<property name="connectionFactory" ref="jedisConnectionFactory"/>
		<property name="keySerializer">
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
		</property>
		<property name="hashKeySerializer">  
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>  
		</property>
		<property name="valueSerializer">
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
		</property>
		<property name="hashValueSerializer">  
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>  
		</property>
		<!--开启事务  -->
		<property name="enableTransactionSupport" value="true"></property>
		
	</bean> 
	<bean id="redisUtil" class="com.dami.util.redis.RedisUtil">
		<property name="redisTemplate" ref="redisTemplate" />
	</bean>
	<!-- redis共享程序session 连接到Redis服务器  -->
	<bean id="redisHttpSessionConfiguration" 
			class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration">
		<property name="maxInactiveIntervalInSeconds" value="1800"/><!-- session过期时间30分钟  -->
		<!-- <property name="redisNamespace" value="ianbase"/> -->
		<!-- <property name="configureRedisAction" value="NO_OP"/> --><!-- 让Spring Session不再执行config命令 -->
		<!-- <property name="httpSessionListeners">
			<list>
				<ref bean="RedisSessionListener" />
			</list>
		</property> -->
	</bean>
	<!-- SpringSession 监听(session创建,销毁) -->
	<bean id="RedisSessionListener"  class="org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter">  
		<constructor-arg name="listeners">
			<list>
				<bean class="com.dami.util.SessionListener" />
			</list>
		</constructor-arg>
	</bean>
	<!-- Spring实现redis键失效监听 -->
	<bean id="messageListener" class="org.springframework.data.redis.listener.adapter.MessageListenerAdapter">
		<constructor-arg>
			<bean class="com.dami.util.redis.RedisMessageDelegateImpl"/>
		</constructor-arg>
	</bean>
	<bean id="redisContainer" class="org.springframework.data.redis.listener.RedisMessageListenerContainer">
		<property name="connectionFactory" ref="jedisConnectionFactory"/>
		<property name="messageListeners">
			<map>
				<entry key-ref="messageListener">
					<bean class="org.springframework.data.redis.listener.ChannelTopic">
						<constructor-arg value="__keyevent@0__:expired"/>
					</bean>
				</entry>
			</map>
		</property>
	</bean>
<!-- redis配置结束 -->

版权声明:著作权归作者所有。

相关推荐

Ruby on Rails多套环境的MySQL数据库yml配置

需要注意的是,host和post需要分别配置。不能在host配置端口,如127.0.0.1:3306。如果把端口配置在host,会报类似的错误:Unknown MySQL server host 'mysql://127.0.0.1:3306' (1)default: &default adapter: mysql2 encoding:

nginx配置Basic认证

最近在搭建kibana时,发现kibana是没有提供认证功能,所以想到给它加一个认证,最简单的就是basic auth认证。下面记录下nginx配置basic认证的过程。添加Basic Auth认证需要先创建密码文件,这里使用htpasswd。如果没有找到htpasswd命令,可以先安装httpd-tools。安装httpd-toolsyum install 

CentOS 7更新为阿里云yum源

进入yum源的目录centos 7yum源目录为/etc/yum.repos.d$cd /etc/yum.repos.d 备份yum源在更新centos 7的yum源前先备份。$ sudo cp CentOS-Base.repo backup/ 如果没有bakcup目录先创建。下载阿里云yum源阿里云yum源列表:http://

Nginx配置WebSocket

Nginx配置WebSocketserver {     listen       80;     server_name  example.com;     location&