applicationContext.xml
<?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:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <bean id="propertyConfigurer" class="util.PropertyConfigurer"> <property name="location"> <value>classpath:param.properties</value> </property> <property name="fileEncoding" value="UTF-8" /> </bean> <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="initialSize" value="5" /> <property name="maxActive" value="20" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 注入dataSource连接资源 --> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">false</prop> <!-- <prop key="hibernate.format_sql">true</prop> --> <prop key="hibernate.connection.autocommit">true</prop> <prop key="hibernate.cache.use_query_cache">false</prop> </props> </property> <property name="mappingLocations"> <list> <value>classpath*:com/user/entity/*.hbm.xml</value> </list> </property> </bean> <bean id="commonDAO" class="com.common.dao.impl.CommonDAOImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <context:component-scan base-package="com" /> <context:annotation-config /> </beans>