applicationContext.xml 3.66 KB
<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:redis="http://www.springframework.org/schema/redis"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd
		http://www.springframework.org/schema/redis http://www.springframework.org/schema/redis/spring-redis.xsd" 
		default-lazy-init="true">

	<!-- Root Context: defines shared resources visible to all other web components -->
	<context:component-scan base-package="com.cjs.site" />
	
	<aop:aspectj-autoproxy proxy-target-class="true" />

	<!-- 加载jdbc.properties文件 -->
	<bean class="com.cjs.site.util.lang.EncryptPropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:config.properties</value>
			</list>
		</property>
	</bean>

	<!-- Kaptcha验证码 -->
	<bean id="captchaProducer" class="com.google.code.kaptcha.impl.DefaultKaptcha">
		<property name="config">
			<bean class="com.google.code.kaptcha.util.Config">
				<constructor-arg type="java.util.Properties">
					<props>
						<prop key="kaptcha.image.width">100</prop>
						<prop key="kaptcha.image.height">40</prop>
						<prop key="kaptcha.textproducer.char.string">0123456789</prop>
						<prop key="kaptcha.textproducer.char.length">4</prop>
						<prop key="kaptcha.textproducer.font.size">30</prop>
						<prop key="kaptcha.border.color">red</prop>
						<prop key="kaptcha.textproducer.font.names">Arial</prop>
						<prop key="kaptcha.obscurificator.impl">com.google.code.kaptcha.impl.WaterRipple</prop>
						<prop key="kaptcha.noise.impl">com.google.code.kaptcha.impl.NoNoise</prop>
					</props>
				</constructor-arg>
			</bean>
		</property>
	</bean>
	
	<!-- spring session -->
	<context:annotation-config />
	
	<bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration">
		<property name="maxInactiveIntervalInSeconds" value="1800" />
	</bean>
	
	<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
		<property name="hostName" value="${${env}.redis.host}" />
		<property name="port" value="${${env}.redis.port}" />
		<property name="poolConfig" ref="jedisPoolConfig" />
	</bean>
	
	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
        <property name="maxIdle" value="300" />
        <property name="maxWaitMillis" value="5000" />
        <property name="testOnBorrow" value="true" />
    </bean>
    
    <bean id="stringRedisSerializer" 
    	class="org.springframework.data.redis.serializer.StringRedisSerializer" />
    
    <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
        <property name="connectionFactory" ref="jedisConnectionFactory" />
        <property name="enableTransactionSupport" value="false" />
        <property name="keySerializer" ref="stringRedisSerializer" />
    </bean>
	
	<import resource="spring-db.xml"/>
</beans>