/**

书写pojo类------》dao接口------》resources下建立同路径的dao.xml------》配置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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<!--dao层配置文件开始-->

<!--配置数据源-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql:///maven"/>
<property name="username" value="root"/>
<property name="password" value="123"/>
</bean>

<!--配置生产SqlSession对象的工厂-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!--扫描pojo包,给包下的所有pojo对象起别名-->
<property name="typeAliasesPackage" value="com.hope.domain"/>
</bean>

<!--扫描接口包路径,生成包下所有接口的代理对象,并且放入到spring容器中-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.hope.dao"/>
</bean>
<!--dao层配置文件结束-->

<!--service层配置文件开始-->

<!--组件扫描配置-->
<context:component-scan base-package="com.hope.service"></context:component-scan>

<!--aop面向切面编程,切面就是切入点和通知的组合-->

<!--配置事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>

<!--配置事务的通知-->
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>

<!--配置切面-->
<aop:config>
<!--切点-->
<aop:pointcut id="pointcut" expression="execution(* com.hope.service.impl.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/>
</aop:config>
<!--service层配置文件结束-->


</beans>

mybatis的dao层和service层的编码设计的配置的更多相关文章

  1. java中Action层、Service层和Dao层的功能区分

    Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO只 ...

  2. DAO层,Service层,Controller层、View层 的分工合作

    DAO层:DAO层主要是做数据持久层的工作,负责与数据库进行联络的一些任务都封装在此,DAO层的设计首先是设计DAO的接口,然后在Spring的配置文件中定义此接口的实现类,然后就可在模块中调用此接口 ...

  3. [转]DAO层,Service层,Controller层、View层

    来自:http://jonsion.javaeye.com/blog/592335 DAO层 DAO 层主要是做数据持久层的工作,负责与数据库进行联络的一些任务都封装在此,DAO层的设计首先是设计DA ...

  4. 搭建DAO层和Service层代码

    第一部分建立实体和映射文件 1 通过数据库生成的实体,此步骤跳过,关于如何查看生成反向工程实体类查看SSH框架搭建教程-反向工程章节 Tmenu和AbstractorTmenu是按照数据库表反向工程形 ...

  5. DAO层,Service层,Controller层、View层

    DAO层:DAO层主要是做数据持久层的工作,负责与数据库进行联络的一些任务都封装在此,DAO层的设计首先是设计DAO的接口,然后在Spring的配置文件中定义此接口的实现类,然后就可在模块中调用此接口 ...

  6. 分层 DAO层,Service层,Controller层、View层

    前部分摘录自:http://blog.csdn.net/zdwzzu2006/article/details/6053006 DAO层:DAO层主要是做数据持久层的工作,负责与数据库进行联络的一些任务 ...

  7. DAO层,Service层,Controller层、View层介绍

    来自:http://jonsion.javaeye.com/blog/592335 DAO层 DAO 层主要是做数据持久层的工作,负责与数据库进行联络的一些任务都封装在此,DAO层的设计首先是设计DA ...

  8. Java中Action层、Service层、Modle层和Dao层的功能区分

    一.Java中Action层.Service层.Modle层和Dao层的功能区分: 首先,这是现在最基本的分层方式,结合了SSH架构. modle层就是对应的数据库表的实体类.(即domain) Da ...

  9. DAO层,Service层,Controller层、View层协同工作机制

    转自 http://www.blogdaren.com/post-2024.html DAO层:DAO层主要是做数据持久层的工 作,负责与数据库进行联络的一些任务都封装在此,DAO层的设计首先是设计D ...

  10. DAO层,Service层,Controller层、View层、entity层

    1.DAO(mapper)层:DAO层主要是做数据持久层的工作,负责与数据库进行联络的一些任务都封装在此,DAO层的设计首先是设计DAO的接口,然后在Spring的配置文件中定义此接口的实现类,然后就 ...

随机推荐

  1. ant生成jmeter测试报告没有数据【已解决】

    1.如下图,在配置build时,到网上找配置文件,配置样式表文件名经常是jmeter-results-detail-report_21.xsl, 3.但是在其他版本可能被不是这个文件名,在jmeter ...

  2. 简单的SQl时间序列生成,每次时间间隔10分钟。

    create table #timeseries(Times datetime not null) go declare @firstdate datetime , @lastdate datetim ...

  3. Typora图片自动上传至码云

    Typora图片自动上传至码云 下载PicGo图片上传工具 PicGo下载地址 下载完毕后打开PicGo,点击插件设置,搜索Gitee,点击安装gitee 2.0.3 码云仓库创建 创建参数是点击设置 ...

  4. CODING添加ssh提示格式错误的问题

    不能去.shh文件夹打开id_rsa.pub文件查看 解决方法: 进入.ssh文件夹,然后右键git bash here 输入代码 cat id_rsa.pub 回车即可

  5. PAT A1024题解——高精度大数相加模板

    PAT:A1024 Palindromic Number A number that will be the same when it is written forwards or backwards ...

  6. [loj6278]数列分块入门2

    做法1 以$K$为块大小分块,并对每一个块再维护一个排序后的结果,预处理复杂度为$o(n\log K )$ 区间修改时将整块打上标记,散块暴力修改并归并排序,单次复杂度为$o(\frac{n}{K}+ ...

  7. [atARC080F]Prime Flip

    构造一个数组$b_{i}$(初始为0),对于操作$[l_{i},r_{i}]$,令$b_{l_{i}}$和$b_{r_{i}+1}$值异或1,表示$i$和$i-1$的差值发生改变,最终即要求若干个$b ...

  8. Github树型插件--Octotree

    octotree 是一款chrome插件,用于将 GitHub 项目代码以树形格式展示,而且在展示的列表中,我们可以下载指定的文件,而不需要下载整个项目. 官网地址:https://www.octot ...

  9. [USACO07NOV]Cow Relays G

    题目大意 给出一张无向连通图(点数小于1000),求S到E经过k条边的最短路. 算法 这是之前国庆模拟赛的题 因为懒 所以就只挑一些题写博客 在考场上写了个dp 然后水到了50分 出考场和神仙们一问才 ...

  10. CODE FESTIVAL 2017 qual C F - Three Gluttons(DP)

    洛谷题面传送门 & Atcoder 题面传送门 DP 好题. 首先考虑如果我们知道 C 吃了哪些寿司,能够还原出多少种符合条件的序列.我们考虑倒着钦定,即,先钦定 A,B,C 三者最后吃的那三 ...