|
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd" >
<!-- enable autowire -->
<context:annotation-config />
<task:annotation-driven/>
<context:component-scan base-package="demo.util,demo.salesorder,demo.person" />
<!-- Configures the @Controller programming model 必须加上这个,不然请求controller时会出现no mapping url错误-->
<mvc:annotation-driven />
<!-- 引入数据库配置文件 -->
<bean >
<property name="locations">
<list>
<value>classpath:sysconfig/jdbc.properties</value>
<value>classpath:sysconfig/redis.properties</value>
</list>
</property>
</bean>
<!-- JDBC -->
<bean destroy-method="close"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" >
<property name="maxActive">
<value>${jdbc.maxActive}</value>
</property>
<property name="initialSize">
<value>${jdbc.initialSize}</value>
</property>
<property name="maxWait">
<value>${jdbc.maxWait}</value>
</property>
<property name="maxIdle">
<value>${jdbc.maxIdle}</value>
</property>
<property name="minIdle">
<value>${jdbc.minIdle}</value>
</property>
<!-- 只要下面两个参数设置成小于8小时(MySql默认),就能避免MySql的8小时自动断开连接问题 -->
<property name="timeBetweenEvictionRunsMillis">
<value>18000000</value>
</property><!-- 5小时 -->
<property name="minEvictableIdleTimeMillis">
<value>10800000</value>
</property><!-- 3小时 -->
<property name="validationQuery">
<value>SELECT 1</value>
</property>
<property name="testOnBorrow">
<value>true</value>
</property>
</bean>
<!-- define the SqlSessionFactory -->
<bean>
<property name="dataSource" ref="defaultDataSource" />
<property name="typeAliasesPackage" value="demo.salesorder,demo.person" />
<!-- 可以单独指定mybatis的配置文件,或者写在本文件里面。 用下面的自动扫描装配(推荐)或者单独mapper -->
<property name="configLocation" value="classpath:sysconfig/mybatis-config.xml" />
</bean>
<!-- 自动扫描并组装MyBatis的映射文件和接口-->
<bean>
<property name="basePackage" value="demo.*.data" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- JDBC END -->
<!-- redis数据源 -->
<bean>
<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>
<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="poolConfig" ref="poolConfig" />
</bean>
<!-- 使用中间类解决RedisCache.jedisConnectionFactory的静态注入,从而使MyBatis实现第三方缓存 -->
<bean>
<property name="jedisConnectionFactory" ref="jedisConnectionFactory"/>
</bean>
<bean></bean>
</beans> |
|
|
|
|
|
|