1、资源文件resources.properties中内容
2、applicationContext.xml中配置
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>-->
<!-------------------------------------------------------------------------->
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="alias" value="proxoolDataSource" />
<property name="driver" value="${connection.driver_class}" />
<property name="driverUrl" value="${connection.url}" />
<property name="user" value="${connection.username}" />
<property name="password" value="${connection.password}" />
<property name="maximumConnectionCount" value="${proxool.maximum.connection.count}" />
<property name="minimumConnectionCount" value="${proxool.minimum.connection.count}" />
<property name="statistics" value="${proxool.statistics}" />
<property name="simultaneousBuildThrottle" value="${proxool.simultaneous.build.throttle}" />
</bean>
<bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/zby/dasic/user/model/UserModel.hbm.xml</value>
<value>com/zby/dasic/evaluation/model/EvaluateItem.hbm.xml</value>
<value>com/zby/dasic/evaluation/model/EvaluateItemDetail.hbm.xml</value>
<value>com/zby/contest/awards/model/Awards.hbm.xml</value>
<value>com/zby/contest/awardscoures/model/AwardsCourse.hbm.xml</value>
<value>com/zby/contest/comment/model/Comment.hbm.xml</value>
<value>com/zby/contest/course/model/Course.hbm.xml</value>
<value>com/zby/contest/coursetype/model/CourseCategory.hbm.xml</value>
<value>com/zby/contest/evaluate/model/Evaluate.hbm.xml</value>
<value>com/zby/contest/events/model/Events.hbm.xml</value>
<value>com/zby/contest/schedule/model/Schedule.hbm.xml</value>
<value>com/zby/contest/schedulecoures/model/ScheduleCourse.hbm.xml</value>
<value>com/zby/info/news/model/News.hbm.xml</value></list></property>
<!-- <property name="mappingDirectoryLocations">把指定路径下面的所有的映射文件全部加载完毕 会加载指定路径下所有的映射文件,配置文件在同一个包下时
<value>classpath:com/etmr/hibernate/transaction/domain</value>
</property> -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.query.substitutions">${hibernate.query.substitutions}</prop>
<prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
<prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">${hibernate.bytecode.use_reflection_optimizer}</prop>
</props></property>
<!--------------------------------------------------------->
<!--通过hibernate.cfg.xml实现上述一段代码,一般不用这一种-->
<!--<bean id="sessionFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>-->
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.hbm2ddl.auto=none
hibernate.show_sql=true
hibernate.query.substitutions=true 1, false 0
hibernate.default_batch_fetch_size=16
hibernate.max_fetch_depth=2
hibernate.bytecode.use_reflection_optimizer=true
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.EhCacheRegionFactory
net.sf.ehcache.configurationResourceName=/ehcache_hibernate.xml
hibernate.cache.use_structured_entries=true
hibernate.generate_statistics=true
connection.driver_class=com.mysql.jdbc.Driver
connection.url=jdbc\:mysql\://192.168.1.27\:3320/emcc_db?useUnicode\=true&characterEncoding\=UTF-8
connection.username=root
connection.password=123456
proxool.maximum.connection.count=10
proxool.minimum.connection.count=5
proxool.statistics=1m,15m,1h,1d
proxool.simultaneous.build.throttle=30
name=admin
password=admin
2、applicationContext.xml中配置
<!-- 解析指定位置的properties文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/resources.properties" />
<!--解析指定位置的properties文件,文件在src下面
etmr<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>-->
<!-------------------------------------------------------------------------->
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="alias" value="proxoolDataSource" />
<property name="driver" value="${connection.driver_class}" />
<property name="driverUrl" value="${connection.url}" />
<property name="user" value="${connection.username}" />
<property name="password" value="${connection.password}" />
<property name="maximumConnectionCount" value="${proxool.maximum.connection.count}" />
<property name="minimumConnectionCount" value="${proxool.minimum.connection.count}" />
<property name="statistics" value="${proxool.statistics}" />
<property name="simultaneousBuildThrottle" value="${proxool.simultaneous.build.throttle}" />
</bean>
<bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/zby/dasic/user/model/UserModel.hbm.xml</value>
<value>com/zby/dasic/evaluation/model/EvaluateItem.hbm.xml</value>
<value>com/zby/dasic/evaluation/model/EvaluateItemDetail.hbm.xml</value>
<value>com/zby/contest/awards/model/Awards.hbm.xml</value>
<value>com/zby/contest/awardscoures/model/AwardsCourse.hbm.xml</value>
<value>com/zby/contest/comment/model/Comment.hbm.xml</value>
<value>com/zby/contest/course/model/Course.hbm.xml</value>
<value>com/zby/contest/coursetype/model/CourseCategory.hbm.xml</value>
<value>com/zby/contest/evaluate/model/Evaluate.hbm.xml</value>
<value>com/zby/contest/events/model/Events.hbm.xml</value>
<value>com/zby/contest/schedule/model/Schedule.hbm.xml</value>
<value>com/zby/contest/schedulecoures/model/ScheduleCourse.hbm.xml</value>
<value>com/zby/info/news/model/News.hbm.xml</value></list></property>
<!-- <property name="mappingDirectoryLocations">把指定路径下面的所有的映射文件全部加载完毕 会加载指定路径下所有的映射文件,配置文件在同一个包下时
<value>classpath:com/etmr/hibernate/transaction/domain</value>
</property> -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.query.substitutions">${hibernate.query.substitutions}</prop>
<prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
<prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">${hibernate.bytecode.use_reflection_optimizer}</prop>
</props></property>
</bean>
<!--------------------------------------------------------->
<!--通过hibernate.cfg.xml实现上述一段代码,一般不用这一种-->
<!--<bean id="sessionFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>-->