spring JpetStore学习笔记(三)
来源:互联网 发布:新手如何做淘宝客服 编辑:程序博客网 时间:2024/05/16 18:31
接下来,看看applicationContext.xml文件
利用PropertyPlaceholderConfigurer类关联资源文件,用$(...)的方式索引各个属性,例如,$(jdbc.url)可以取得资源文件中jdbc.url所设定的值.
声明bean petStore,感觉这里是将上述的五个DAO的bean注入PetStore方法接口的实现类PetStoreImpl中,用于持久层操作.
声明式事务配置,详细介绍可参照另一篇笔记 spring框架的事务管理
接下来是dataAccessContext-local.xml文件
声明数据源bean
声明事务的资源管理类
此处声明ibatis的配置map 文件的位置
定义DAO的bean,为接口实现类配置注入sqlMapClient的bean这里只贴一个,其他类似。
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/mail.properties</value>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>WEB-INF/mail.properties</value>
<value>WEB-INF/jdbc.properties</value>
</list>
</property>
</bean>
<bean id="petStore" class="org.springframework.samples.jpetstore.domain.logic.PetStoreImpl">
<property name="accountDao" ref="accountDao"/>
<property name="categoryDao" ref="categoryDao"/>
<property name="productDao" ref="productDao"/>
<property name="itemDao" ref="itemDao"/>
<property name="orderDao" ref="orderDao"/>
</bean>
<property name="accountDao" ref="accountDao"/>
<property name="categoryDao" ref="categoryDao"/>
<property name="productDao" ref="productDao"/>
<property name="itemDao" ref="itemDao"/>
<property name="orderDao" ref="orderDao"/>
</bean>
<aop:config>
<aop:advisor pointcut="execution(* *..PetStoreFacade.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*"/>
<tx:method name="update*"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:advisor pointcut="execution(* *..PetStoreFacade.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*"/>
<tx:method name="update*"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
接下来是dataAccessContext-local.xml文件
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="accountDao" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
- spring JpetStore学习笔记(三)
- spring JpetStore学习笔记(一)
- spring JpetStore学习笔记(二)
- spring JpetStore学习笔记(四)
- spring 学习jpetstore整理(-)
- spring-jpetstore学习
- spring-jpetstore学习
- Spring JPetStore学习(一)配置JPetStore
- Spring 版的 JpetStore 中的 AccountFormController 学习笔记
- spring-jpetstore 学习整理(二)
- Mybatis JPetStore 学习笔记(一)
- spring-jpetstore学习之(一)jpetstore 安装篇
- 学习Spring附带源码jpetstore安装配置
- Jpetstore项目学习笔记(一)
- Jpetstore项目学习笔记(一)
- Spring 学习笔记 三
- spring学习笔记三
- spring学习笔记(三)
- [网络基础知识]==-IP地址精解-==
- 网络字节序和主机字节序
- 系统安全:深度解析Windows最令人迷惑的两大进程
- JTAG在线下载和通过非JTAG下载配置方式有什么区别?
- 自己写的网上的一些试题C的实现
- spring JpetStore学习笔记(三)
- 系统安全:了解Cookie与浏览器的关系 拒绝"被黑"
- 从.NET类库代码来看ASP.NET运行时
- 远程调试配置(转)
- 如何确定任务优先级?
- Annotation转载
- HTML 个人总结
- Java Annotation入门
- 简单的YCAA