<?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:cache="http://www.springframework.org/schema/cache"
|
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
|
xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang"
|
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
|
xmlns:p="http://www.springframework.org/schema/p" xmlns:task="http://www.springframework.org/schema/task"
|
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
|
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
|
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
|
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
|
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
|
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.2.xsd
|
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.2.xsd
|
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
|
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd
|
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
|
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
|
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
|
<!-- 必须采用java8 -->
|
|
|
<!-- 组件扫描 -->
|
<context:component-scan base-package="com.yeshi.fanli">
|
</context:component-scan>
|
<!--配置spring 注解 -->
|
<context:annotation-config />
|
<!-- 默认的注解映射的支持 -->
|
<mvc:annotation-driven />
|
<!-- Spring AOP支持 -->
|
<aop:aspectj-autoproxy proxy-target-class="true" />
|
|
|
<!-- 引入配置文件 -->
|
<bean
|
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
<property name="locations"> <!-- PropertyPlaceholderConfigurer类中有个locations属性,接收的是一个数组,即我们可以在下面配好多个properties文件 -->
|
<array>
|
<value>classpath:redis.properties</value>
|
<value>classpath:druid.properties</value>
|
<value>classpath:mongo.properties</value>
|
</array>
|
</property>
|
</bean>
|
|
<!--异步定义推荐方式 <task:executor id="executor" pool-size="15" /> <task:scheduler
|
id="scheduler" pool-size="30" /> <task:annotation-driven executor="executor"
|
scheduler="scheduler" /> -->
|
|
<bean id="multipartResolver"
|
class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
|
<bean
|
class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
|
|
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
|
init-method="init" destroy-method="close">
|
|
<!-- 基本属性 url、user、password -->
|
<!-- rdsw9f61e43320loxs25.mysql.rds.aliyuncs.com -->
|
<!-- <property name="url" value="jdbc:mysql://127.0.0.1:3306/ec_quan?useUnicode=true&characterEncoding=utf-8"
|
/> <property name="username" value="root" /> <property name="password" value="123456"
|
/> -->
|
|
<!-- gz-cdb-r13d0yi9.sql.tencentcdb.com:62929 172.16.16.17:3306 -->
|
|
<property name="url" value="${druid.url}" />
|
<property name="username" value="${druid.username}" />
|
<property name="password" value="${druid.password}" />
|
|
|
|
<!-- 配置初始化大小、最小、最大 -->
|
<property name="initialSize" value="${druid.initialSize}" />
|
<property name="minIdle" value="${druid.minIdle}" />
|
<property name="maxActive" value="${druid.maxActive}" />
|
|
<!-- 配置获取连接等待超时的时间 -->
|
<property name="maxWait" value="${druid.maxWait}" />
|
|
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
|
<property name="timeBetweenEvictionRunsMillis" value="${druid.timeBetweenEvictionRunsMillis}" />
|
<!-- 超过时间限制是否回收 -->
|
<property name="removeAbandoned" value="true" />
|
<!-- 超时时间;单位为秒。180秒=3分钟 -->
|
<property name="removeAbandonedTimeout" value="180" />
|
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
|
<property name="minEvictableIdleTimeMillis" value="${druid.minEvictableIdleTimeMillis}" />
|
|
<property name="validationQuery" value="SELECT 'x'" />
|
<property name="testWhileIdle" value="true" />
|
<property name="testOnBorrow" value="false" />
|
<property name="testOnReturn" value="false" />
|
|
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
|
<property name="poolPreparedStatements" value="false" />
|
<property name="maxPoolPreparedStatementPerConnectionSize"
|
value="20" />
|
<!-- 配置监控统计拦截的filters -->
|
<property name="filters" value="stat" />
|
</bean>
|
|
<bean id="sessionFactory"
|
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
|
<property name="dataSource" ref="dataSource"></property>
|
<property name="hibernateProperties">
|
<props>
|
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
|
<!-- <prop key="hibernate.hbm2ddl.auto">false</prop> -->
|
<prop key="hibernate.show_sql">true</prop>
|
</props>
|
</property>
|
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
|
<!-- 自动扫描实体 -->
|
<property name="packagesToScan" value="com.yeshi.fanli.entity" />
|
</bean>
|
|
<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
|
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
<property name="dataSource" ref="dataSource" />
|
<property name="configLocation" value="classpath:mybatis-config.xml" />
|
<!-- 自动扫描mapping.xml文件 -->
|
<property name="mapperLocations" value="classpath:com/yeshi/fanli/mapping/**/*.xml"></property>
|
</bean>
|
|
|
<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
|
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
<property name="basePackage" value="com.yeshi.fanli.dao.mybatis" />
|
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
|
</bean>
|
|
|
|
|
|
|
<!-- 事物 -->
|
<bean id="transactionManager"
|
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
|
<property name="sessionFactory" ref="sessionFactory" />
|
</bean>
|
|
<tx:annotation-driven transaction-manager="transactionManager"
|
proxy-target-class="true" />
|
|
|
|
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
|
<property name="sessionFactory" ref="sessionFactory" />
|
</bean>
|
|
<mvc:resources location="/client/html/" mapping="/client/html/**" />
|
<mvc:resources location="/client/css/" mapping="/client/css/**" />
|
<mvc:resources location="/client/img/" mapping="/client/img/**" />
|
<mvc:resources location="/client/js/" mapping="/client/js/**" />
|
<mvc:resources location="/client/fonts/" mapping="/client/fonts/**" />
|
<mvc:resources location="/client/layer/" mapping="/client/layer/**" />
|
<mvc:resources location="/client/fan/" mapping="/client/fan/**" />
|
<mvc:resources location="/client/gonglue/" mapping="/client/gonglue/**" />
|
<mvc:resources location="/client/fan_client/" mapping="/client/fan_client/**" />
|
<!-- <mvc:resources location="/client/" mapping="/client/**"/> -->
|
<mvc:resources location="/admin/" mapping="/admin/**" />
|
<mvc:resources location="/druid/" mapping="/druid/**" />
|
<mvc:resources location="/client/share/" mapping="/client/share/**" />
|
<mvc:resources location="/client/h5/" mapping="/client/h5/**" />
|
<mvc:resources location="/client/jsp/share/css/" mapping="/client/jsp/share/css/**" />
|
<mvc:resources location="/client/jsp/share/img/" mapping="/client/jsp/share/img/**" />
|
<mvc:resources location="/client/jsp/share/js/" mapping="/client/jsp/share/js/**" />
|
<mvc:resources location="/client/jsp/share2/css/"
|
mapping="/client/jsp/share2/css/**" />
|
<mvc:resources location="/client/jsp/share2/img/"
|
mapping="/client/jsp/share2/img/**" />
|
<mvc:resources location="/client/jsp/share2/js/" mapping="/client/jsp/share2/js/**" />
|
<mvc:resources location="/client/jsp/share2/css/"
|
mapping="/client/jsp/share2/css/**" />
|
<mvc:resources location="/client/jsp/share2/img/"
|
mapping="/client/jsp/share2/img/**" />
|
<mvc:resources location="/client/jsp/share2/js/" mapping="/client/jsp/share2/js/**" />
|
|
<mvc:resources location="/web/" mapping="/web/**" />
|
|
<!-- 业务Bean配置 -->
|
<!-- 拦截器定义 -->
|
<mvc:interceptors>
|
<!-- 使用bean定义一个Interceptor,直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 -->
|
<bean class="com.yeshi.fanli.interceptor.EncodingInterceptor" />
|
<bean class="com.yeshi.fanli.interceptor.CommonInterceptor" />
|
</mvc:interceptors>
|
|
<task:annotation-driven scheduler="qbScheduler"
|
mode="proxy" />
|
<task:scheduler id="qbScheduler" pool-size="50" />
|
|
<!-- 异步方法 -->
|
<task:executor id="pushExecutor" pool-size="15-1000"
|
queue-capacity="100" keep-alive="20" />
|
|
<!-- 缓存注解支持 -->
|
<cache:annotation-driven cache-manager="cacheManager" />
|
<bean id="cacheManagerFactory"
|
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
|
<property name="configLocation" value="classpath:ehcache.xml" />
|
</bean>
|
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
|
<property name="cacheManager" ref="cacheManagerFactory" />
|
</bean>
|
|
<bean id="appProperty"
|
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
<property name="locations">
|
<array>
|
<value>classpath:app.properties</value>
|
</array>
|
</property>
|
</bean>
|
|
|
|
<!-- redis连接池 -->
|
<bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig">
|
<property name="maxActive" value="${redis.max_active}"></property>
|
<property name="maxIdle" value="${redis.max_idle}"></property>
|
<property name="maxWait" value="${redis.max_wait}"></property>
|
<property name="testOnBorrow" value="${redis.test_on_borrow}"></property>
|
</bean>
|
|
<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
|
<constructor-arg name="poolConfig" ref="jedisConfig"></constructor-arg>
|
<constructor-arg name="host" value="${redis.addr}"></constructor-arg>
|
<constructor-arg name="port" value="${redis.port}"></constructor-arg>
|
<constructor-arg name="timeout" value="${redis.timeout}"></constructor-arg>
|
<constructor-arg name="password" value="${redis.auth}"></constructor-arg>
|
</bean>
|
|
<!-- redis连接工厂 -->
|
<bean id="connectionFactory"
|
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
|
<property name="hostName" value="${redis.addr}"></property>
|
<property name="port" value="${redis.port}"></property>
|
<property name="password" value="${redis.auth}"></property>
|
<property name="poolConfig" ref="jedisConfig"></property>
|
</bean>
|
|
<!-- redis操作模板,这里采用尽量面向对象的模板 -->
|
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
|
<property name="connectionFactory" ref="connectionFactory" />
|
<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>
|
|
|
<!-- mongodb -->
|
<mongo:mongo id="mongo" host="${mongo.host}" port="${mongo.port}">
|
<mongo:options connections-per-host="${mongo.connectionsPerHost}"
|
threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}"
|
connect-timeout="${mongo.connectTimeout}" max-wait-time="${mongo.maxWaitTime}"
|
auto-connect-retry="${mongo.autoConnectRetry}" socket-keep-alive="${mongo.socketKeepAlive}"
|
socket-timeout="${mongo.socketTimeout}" slave-ok="${mongo.slaveOk}"
|
write-number="1" write-timeout="0" write-fsync="true" />
|
</mongo:mongo>
|
|
|
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
|
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
|
</bean>
|
<bean id="mongoDbFactory"
|
class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
|
<constructor-arg name="mongo" ref="mongo" />
|
<constructor-arg name="databaseName" value="${mongo.dbname}" />
|
<constructor-arg name="credentials" ref="userCredentials" />
|
<constructor-arg name="authenticationDatabaseName"
|
value="admin" />
|
</bean>
|
<bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials">
|
<constructor-arg name="username" value="${mongo.username}" />
|
<constructor-arg name="password" value="${mongo.password}" />
|
</bean>
|
|
<bean id="jobFactory" class="com.yeshi.fanli.job.JobFactory"></bean>
|
|
<bean id="scheduler" name="Scheduler" lazy-init="false"
|
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
<property name="jobFactory" ref="jobFactory"></property>
|
</bean>
|
|
|
<!-- Spring线程池 -->
|
<bean id="taskExecutor"
|
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
|
<!-- 线程池维护线程的最少数量 -->
|
<property name="corePoolSize" value="100" />
|
<!-- 线程池维护线程所允许的空闲时间 -->
|
<property name="keepAliveSeconds" value="30000" />
|
<!-- 线程池维护线程的最大数量 -->
|
<property name="maxPoolSize" value="1000" />
|
<!-- 线程池所使用的缓冲队列 -->
|
<property name="queueCapacity" value="200" />
|
</bean>
|
|
|
</beans>
|