|
@@ -1,46 +1,55 @@
|
|
|
-<?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:aop="http://www.springframework.org/schema/aop"
|
|
|
- xmlns:mvc="http://www.springframework.org/schema/mvc"
|
|
|
- xmlns:context="http://www.springframework.org/schema/context"
|
|
|
- xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
|
+<?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:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
|
|
+ xmlns:context="http://www.springframework.org/schema/context"
|
|
|
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
|
http://www.springframework.org/schema/mvc
|
|
|
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
|
|
http://www.springframework.org/schema/context
|
|
|
http://www.springframework.org/schema/context/spring-context.xsd
|
|
|
http://www.springframework.org/schema/aop
|
|
|
- http://www.springframework.org/schema/aop/spring-aop-4.3.xsd" >
|
|
|
-
|
|
|
+ http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">
|
|
|
+
|
|
|
<!-- 加载配置文件 -->
|
|
|
- <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
|
|
- <property name="locations">
|
|
|
- <list>
|
|
|
- <value>classpath:jdbc.properties</value>
|
|
|
- </list>
|
|
|
- </property>
|
|
|
- </bean>
|
|
|
-
|
|
|
+ <bean id="propertyConfigurer"
|
|
|
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
|
|
+ <property name="locations">
|
|
|
+ <list>
|
|
|
+ <value>classpath:jdbc.properties</value>
|
|
|
+ </list>
|
|
|
+ </property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
<!-- 数据源的配置 -->
|
|
|
- <bean id = "dataSource" class="org.apache.commons.dbcp.BasicDataSource">
|
|
|
- <property name="driverClassName" value = "${jdbc.driver}"></property>
|
|
|
- <property name="url" value = "${jdbc.url}"></property>
|
|
|
- <property name="username" value = "${jdbc.username}"></property>
|
|
|
- <property name="password" value = "${jdbc.password}"></property>
|
|
|
+ <bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
|
|
|
+ <property name="driverClassName" value="${jdbc.driver}"></property>
|
|
|
+ <property name="jdbcUrl" value="${jdbc.url}"></property>
|
|
|
+ <property name="username" value="${jdbc.username}"></property>
|
|
|
+ <property name="password" value="${jdbc.password}"></property>
|
|
|
+ <!-- 连接只读数据库时配置为true, 保证安全 -->
|
|
|
+ <property name="readOnly" value="false" />
|
|
|
+ <!-- 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 缺省:30秒 -->
|
|
|
+ <property name="connectionTimeout" value="30000" />
|
|
|
+ <!-- 一个连接idle状态的最大时长(毫秒),超时则被释放(retired),缺省:10分钟 -->
|
|
|
+ <property name="idleTimeout" value="600000" />
|
|
|
+ <!-- 一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒,参考MySQL
|
|
|
+ wait_timeout参数(show variables like '%timeout%';) -->
|
|
|
+ <property name="maxLifetime" value="1800000" />
|
|
|
+ <property name="maximumPoolSize" value="10" />
|
|
|
</bean>
|
|
|
-
|
|
|
+
|
|
|
<!-- session工厂 -->
|
|
|
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
- <property name="dataSource" ref="dataSource"/>
|
|
|
- <property name="typeAliasesPackage" value="com.fuzamei.entity"/>
|
|
|
- <property name="mapperLocations" value="classpath:com/fuzamei/mapper/*.xml"/>
|
|
|
- <property name="configLocation" value = "classpath:mybatis-config.xml"/>
|
|
|
+ <property name="dataSource" ref="dataSource" />
|
|
|
+ <property name="typeAliasesPackage" value="com.fuzamei.entity" />
|
|
|
+ <property name="mapperLocations" value="classpath:com/fuzamei/mapper/*.xml" />
|
|
|
+ <property name="configLocation" value="classpath:mybatis-config.xml" />
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
+ <property name="basePackage" value="com.fuzamei.mapperInterface" />
|
|
|
</bean>
|
|
|
-
|
|
|
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
- <property name="basePackage" value="com.fuzamei.mapperInterface"/>
|
|
|
- </bean>
|
|
|
-
|
|
|
+
|
|
|
</beans>
|