applicationContext.xml 配置说明
2014-03-07 22:22
176 查看
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 配置数据源,使用DBCP数据源 -->
<bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">
<!-- MySQL数据库的驱动 -->
<property name="driveClassName"value="com.mysql.jdbc.Driver" />
<!-- 数据库的URL -->
<property name="url"value="jdbc:mysql:///newsboard"/>
<!-- 指定数据库的用户名 -->
<property name="username" value="root"/>
<!-- 指定数据库的密码 -->
<property name="password"value="123"/>
<!-- 指定数据库的最大连接数 -->
<property name="maxActive"value="100"/>
<!-- 指定数据库的最大空闲连接数 -->
<property name="maxIdle"value="30"/>
<!-- 指定数据库的最大等待数 -->
<property name="maxWait"value="1000"/>
<!-- 指定数据库的默认自动提交 -->
<property name="defaultAutoCommit"value="true"/>
<!-- 指定数据库的连接超时时是否启动删除 -->
<property name="removeAbandoned"value="true"/>
<!-- 指定数据库的删除数据库连接的超时时长 -->
<property name="removeAbandonedTimeout"value="60"/>
<property name="logAbandoned"value="true"/>
</bean>
<!-- 配置Hibernate的SessionFactory-->
<bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 依赖注入SessionFactory所需的DataSource-->
<property name="dataSource"ref="dataSource"/>
<!-- 加载所有的映射文件 -->
<propertyname="mappingResource">
<!-- 下面列出所有的持久化映射文件 -->
<list>
<value>org/yeeku/model/User.hbm.xml</value>
<value>org/yeeku/model/News.hbm.xml</value>
<value>org/yeeku/model/NewsReview.hbm.xml</value>
<value>org/yeeku/model/Category.hbm.xml</value>
</list>
</property>
<!-- 下面指定Hibernate的属性 -->
<propertyname="hibernateProperties">
<props>
<!--下面指定Hibernate使用的数据库方言 -->
<propkey="hibernate.dialect">org.hibernate.dialect.MySQLDBDialect</prop>
</props>
</property>
</bean>
<!-- 配置DAO组件,必须提供DAO的实现类 -->
<bean id="dao"class="org.yeeku.dao.hibernate.BaseDAOHibernate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 配置DAO组件,必须提供DAO的实现类 -->
<bean id="newsDAO"class="org.yeeku.dao.hibernate.NewsDAOHibernate">
<property name="sessionFactory"ref="sessionFactory"/>
</bean>
<!-- 定义事务模板类,模板类增加abstract="true"属性-->
<bean id="txProxyTemplate" abstract="true"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"ref="transactionManager">
<props>
<!-- 所以save开始的方法的事务属性 -->
<propkey="save*">PROPAGATION_REQUIRED</prop>
<!-- 所有以remove开始的方法的事务属性 -->
<propkey="remove">PROPAGATION_REQUIRED</prop>
<!-- 其他方法的事务属性 -->
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<!-- 配置具体的业务逻辑层组件的事务代理 -->
<bean id="manager"parent="txProxyTemplate">
<!-- 生成业务代理之前,必须使用target制定需要生成代理的目标bean,
目标bean采用嵌套bean的方式定义 -->
<property name="target">
<beanclass="org.yeeku.service.impl.BaseManager">
<!-- 定义嵌套bean所使用的DAO组件 -->
<property name="dao"ref="dao"/>
</bean>
</property>
</bean>
<!-- 配置目标bean代理对象 -->
<bean id="facade"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<!-- 为代理工厂bean注入事务管理器 -->
<property name="transactionManager"ref="transactionManager"/>
<!-- 定义代理的目标bean 此处的目标bean,必须是容器中真实存在的bean实例-->
<property name="target"ref="facadeManager"/>
<!-- 确定生成事务代理的事务属性 -->
<propertyname="transactionAttributes">
<props>
<propkey="save*">PROPAGATION_REQUIRED</prop>
<propkey="remove*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
</beans>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN""http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 配置数据源,使用DBCP数据源 -->
<bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"destroy-method="close">
<!-- MySQL数据库的驱动 -->
<property name="driveClassName"value="com.mysql.jdbc.Driver" />
<!-- 数据库的URL -->
<property name="url"value="jdbc:mysql:///newsboard"/>
<!-- 指定数据库的用户名 -->
<property name="username" value="root"/>
<!-- 指定数据库的密码 -->
<property name="password"value="123"/>
<!-- 指定数据库的最大连接数 -->
<property name="maxActive"value="100"/>
<!-- 指定数据库的最大空闲连接数 -->
<property name="maxIdle"value="30"/>
<!-- 指定数据库的最大等待数 -->
<property name="maxWait"value="1000"/>
<!-- 指定数据库的默认自动提交 -->
<property name="defaultAutoCommit"value="true"/>
<!-- 指定数据库的连接超时时是否启动删除 -->
<property name="removeAbandoned"value="true"/>
<!-- 指定数据库的删除数据库连接的超时时长 -->
<property name="removeAbandonedTimeout"value="60"/>
<property name="logAbandoned"value="true"/>
</bean>
<!-- 配置Hibernate的SessionFactory-->
<bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 依赖注入SessionFactory所需的DataSource-->
<property name="dataSource"ref="dataSource"/>
<!-- 加载所有的映射文件 -->
<propertyname="mappingResource">
<!-- 下面列出所有的持久化映射文件 -->
<list>
<value>org/yeeku/model/User.hbm.xml</value>
<value>org/yeeku/model/News.hbm.xml</value>
<value>org/yeeku/model/NewsReview.hbm.xml</value>
<value>org/yeeku/model/Category.hbm.xml</value>
</list>
</property>
<!-- 下面指定Hibernate的属性 -->
<propertyname="hibernateProperties">
<props>
<!--下面指定Hibernate使用的数据库方言 -->
<propkey="hibernate.dialect">org.hibernate.dialect.MySQLDBDialect</prop>
</props>
</property>
</bean>
<!-- 配置DAO组件,必须提供DAO的实现类 -->
<bean id="dao"class="org.yeeku.dao.hibernate.BaseDAOHibernate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 配置DAO组件,必须提供DAO的实现类 -->
<bean id="newsDAO"class="org.yeeku.dao.hibernate.NewsDAOHibernate">
<property name="sessionFactory"ref="sessionFactory"/>
</bean>
<!-- 定义事务模板类,模板类增加abstract="true"属性-->
<bean id="txProxyTemplate" abstract="true"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"ref="transactionManager">
<props>
<!-- 所以save开始的方法的事务属性 -->
<propkey="save*">PROPAGATION_REQUIRED</prop>
<!-- 所有以remove开始的方法的事务属性 -->
<propkey="remove">PROPAGATION_REQUIRED</prop>
<!-- 其他方法的事务属性 -->
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<!-- 配置具体的业务逻辑层组件的事务代理 -->
<bean id="manager"parent="txProxyTemplate">
<!-- 生成业务代理之前,必须使用target制定需要生成代理的目标bean,
目标bean采用嵌套bean的方式定义 -->
<property name="target">
<beanclass="org.yeeku.service.impl.BaseManager">
<!-- 定义嵌套bean所使用的DAO组件 -->
<property name="dao"ref="dao"/>
</bean>
</property>
</bean>
<!-- 配置目标bean代理对象 -->
<bean id="facade"class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<!-- 为代理工厂bean注入事务管理器 -->
<property name="transactionManager"ref="transactionManager"/>
<!-- 定义代理的目标bean 此处的目标bean,必须是容器中真实存在的bean实例-->
<property name="target"ref="facadeManager"/>
<!-- 确定生成事务代理的事务属性 -->
<propertyname="transactionAttributes">
<props>
<propkey="save*">PROPAGATION_REQUIRED</prop>
<propkey="remove*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
</beans>
相关文章推荐
- Spring ApplicationContext.xml配置的12个技巧和Bean属性说明
- spring+hibernate:在applicationCOntext.XML中配置C3P0参数说明
- applicationContext.xml 配置说明
- applicationContext.xml 配置说明
- springMVC之applicationcontext.xml配置说明
- applicationContext.xml 配置说明
- springMVC之applicationcontext.xml配置说明
- applicationContext.xml 配置说明
- applicationContext.xml配置说明
- Spring ApplicationContext.xml配置的12个技巧和Bean属性说明
- spring中applicationContext.xml在web.xml中的配置路径说明
- Spring+Hibernate:在applicationContext.xml中配置C3P0参数说明
- spring applicationContext.xml 文件头的配置说明
- applicationContext.xml 配置说明
- applicationContext.xml 配置说明
- spring+hibernate:在applicationCOntext.XML中配置C3P0参数说明Attempted to use a closed or broken resource pool
- Spring ApplicationContext.xml配置的12个技巧和Bean属性说明
- Spring ApplicationContext.xml配置的12个技巧和Bean属性说明
- spring+hibernate:在applicationCOntext.XML中配置C3P0参数说明
- applicationContext.xml 配置模板