p:configLocation="classpath:hibernate.cfg.xml"/>①
如①处所示,通过 " 属性指定了一个 配置文件。如果
有多个 配置文件,则可以通过 "属性指定,多个文件
之间用逗号分隔。
"# 将利用 配置文件创建一个
代理对象,以便和 的事务管理机制配合工作:当数据
访问代码使用 时,可以获取线程绑定的 ,不管工作在
本地或全局的事务,都能正确参与到当前的 事务管理中去。
2 )更具 Spring 风格的配置
对 技术的一个重要支持就是提供统一的数据源管理机制,也许更
多的开发者更愿意使用 配置数据源,即在 容器中定义数据源、
指定映射文件、设置 控制属性等信息,完成集成组装的工作,完全
抛开 (# 配置文件,如下面代码所示。
<?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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<context:property-placeholder location="classpath:jdbc.properties"/>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
评论0
最新资源