把两个xml文件放入src中
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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-lazy-init="true">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
<!--
<value>/WEB-INF/jdbc.properties</value>
-->
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver" value="${db.driver}"/>
<property name="driverUrl" value="${db.url}"/>
<property name="user" value="${db.user}"/>
<property name="password" value="${db.password}"/>
<property name="alias" value="${db.alias}"/>
<property name="houseKeepingTestSql" value="${db.houseKeepingTestSql}"/>
<property name="maximumConnectionCount" value="${db.maximumConnectionCount}"/>
<property name="minimumConnectionCount" value="${db.minimumConnectionCount}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 引用数据源 -->
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="annotatedClasses">
<list>
<value>com.zinc.entity.ChinaCity</value>
<value>com.zinc.entity.ExchangeVolume</value>
<value>com.zinc.entity.FreindsInfo</value>
<value>com.zinc.entity.Users</value>
<value>com.zinc.entity.UserInfo</value>
<value>com.zinc.entity.ResearchOption</value>
<value>com.zinc.entity.ResearchTitle</value>
<value>com.zinc.entity.Support</value>
<value>com.zinc.entity.TopicsUsers</value>
<value>com.zinc.entity.Topics</value>
<value>com.zinc.entity.UserResearchOption</value>
<value>com.zinc.entity.Video</value>
<value>com.zinc.entity.VideoType</value>
<value>com.zinc.entity.VideoUsers</value>
<value>com.zinc.entity.DetermineVote</value>
<value>com.zinc.entity.Wordcensor</value>
<value>com.zinc.entity.Survey</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="connection.useUnicode">true</prop>
<prop key="connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.jdbc.fetch_size">20</prop>
<prop key="hibernate.query.substitutions">true 1, false 0</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
<prop key="hibernate.cache.use_structured_entries">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path"></prop>
</props>
</property>
</bean>
<!-- 事务配置 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 使用annotation 自动注册bean,并检查@Required,@Autowired的属性已被注入 -->
<context:annotation-config/>
<context:component-scan base-package="com.zinc" />
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="txManager" />
</beans>
jdbc.properties
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/zinc?useUnicode=true&characterEncoding=utf-8
db.user=root
db.password=root
db.alias=MySqlPool
db.houseKeepingTestSql=select 1
db.characterEncoding=utf-8
db.maximumConnectionCount=30
db.minimumConnectionCount=5
分享到:
相关推荐
Spring ApplicationContext.xml配置的12个技巧演示教学.pdf
Spring applicationContext.xml常见部分属性的使用备注
本篇文章主要介绍了详解spring applicationContext.xml 配置文件 ,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Spring Boot技术知识点:如何读取不同路径里的applicationContext.xml配置文件4
spring4的“所有jar包”+applicationContext.xml+web.xml====全套
spring+jpa的applicationContext.xml配置
包含applicationContext.xml、db.properties、log4j.properties、spring-mvc.xml文件,方便搭建,省去写代码。。
详解Spring的applicationContext.xml文件代码:
applicationContext.xml+hiberniate属性+Session属性+自动代理+拦截器!!!! 上传的限制去除了jar包!
spring定时任务必须的包和spring配置说明
Spring Boot技术知识点:如何读取不同路径里的applicationContext.xml配置文件6
Spring Boot技术知识点:如何读取不同路径里的applicationContext.xml配置文件1
NULL 博文链接:https://mutourenoo.iteye.com/blog/1156865
Spring Boot技术知识点:如何读取不同路径里的applicationContext.xml配置文件
Spring Boot技术知识点:如何读取不同路径里的applicationContext.xml配置文件3
Spring Boot技术知识点:如何读取不同路径里的applicationContext.xml配置文件5
Spring[applicationContext.xml]灵活性代理