创建service相关文件

创建applicationContext-service.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 扫描包加载Service实现类 -->
<context:component-scan base-package="com.taotao.service"></context:component-scan>
</beans>

配置事务

applicationContext-trans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"> <!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 数据源 -->
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 传播行为 -->
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="select*" propagation="SUPPORTS" read-only="true" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 切面 -->
<aop:config>
<aop:advisor advice-ref="txAdvice"
pointcut="execution(* com.taotao.service.*.*(..))" />
</aop:config>
</beans>

报错先不用管

maven项目创建5 service层整合的更多相关文章

  1. maven项目创建4 dao层整合

    项目配置文件要放在打包成war包的web项目中 创建文件步骤 1    SqlMapConfig.xml <?xml version="1.0" encoding=" ...

  2. maven项目创6 表现层整合

    springmvc.xm创建l 和 web.xml配置    ,报错先不管 springmvc.xml com.taotao.controller   空包 其中    资源映射   是等 web.x ...

  3. ssm框架整合+maven项目创建

    在引入外部maven插件后就可以创建一个maven项目了,这篇文章主要介绍ssm框架的整合和如何创建一个maven项目 1.在开发工具的项目空白区单击右键,依次选择New.Other,会出现如下界面, ...

  4. Maven学习 五 Maven项目创建(1)jar项目

    第一步:Maven项目的创建 File->new->Maven project. 点击下一步 上方的两个多选框选上,第一个是不使用archetype 原型模板,第二个是使用默认工作空间 点 ...

  5. IntelliJ IDEA 进行Maven项目创建build

    IntelliJ IDEA 进行Maven项目创建build 1,文件-新建-maven 项目:2,编写pom.xml文件:3,鼠标放到左下,然后选择Maven Projects,然后可以查看项目信息 ...

  6. Eclipse+Maven 项目创建

    ★:jar包下载不了的话可能是镜像里没有这个版本,换个低版本的就行 ★:eclipse工程validating很慢,可以先关掉验证(一般对项目没什么影响) ★:eclipse工程pom.xml文件报错 ...

  7. 详解Maven项目利用java service wrapper将Java程序生成Windows服务

    在项目的开发中,有时候需要将Java应用程序打包成Windows服务,我们就直接可以通过windows的服务来启动和关闭java程序了. 本博文将通过有两种方法实现该功能,手动创建法和Maven自动打 ...

  8. Maven学习 七 Maven项目创建(2)war项目

    一.web项目的目录结构 如果手动创建一个java  web项目,其基本的目录结构包括:METE-INF,WEB-INF,以及WEB-INF下必须包含一个web.xml文件 二.使用Maven创建wa ...

  9. springmvc 项目完整示例09 maven项目创建

    需求表均同springmvc案例 此处只是使用maven 注意,以下所有需要建立在你的eclipse等已经集成配置好了maven了,说白了就是新建项目的时候已经可以找到maven了 没有的话需要安装m ...

随机推荐

  1. BUUOJ reverse 不一样的flag

    不一样的flag 是不是做习惯了常规的逆向题目?试试这道题,看你在能不能在程序中找到真正的flag!注意:flag并非是flag{XXX}形式,就是一个’字符串‘,考验眼力的时候到了! 注意:得到的 ...

  2. Palindromic Substrings

    Given a string, your task is to count how many palindromic substrings in this string. The substrings ...

  3. 微信多开脚本(Windows,Mac)

    微信多开 以下内容仅用于学习使用.严禁用于非法用途,违者自负. Windows 多开 Windows 版本的微信在一些比较新的版本好像限制了多开,我们这里提供一个版本(也是官方的).https://p ...

  4. 如何解决Oracle11g使用dmp命令无法导出空表问题

    如何解决Oracle11g使用dmp命令无法导出空表问题 导出:exp  username/password@orcl file=路径 tables=(tb1)    //tables=(tb1)可有 ...

  5. Maven下载安装测试

    一.Maven下载 在Maven官网下载压缩包 二.安装 解压后目录如下 bin目录包含mvn的运行脚本 boot目录包含一个类加载器的框架,加载自己的类库 conf是配置文件目录 lib目录包含一些 ...

  6. # 深圳杯D题爬取电视收视率排行榜

    目录 深圳杯D题爬取电视收视率排行榜 站点分析 代码实现 深圳杯D题爬取电视收视率排行榜 站点分析 http://www.tvtv.hk/archives/category/tv 每天的排行版通过静态 ...

  7. position详解

    本文旨在普及一下position的用法,CSS中position的使用率相当之高,对于新入行的小白,不仅要知其然,还要知其所以然. position(定位类型),主要有4种属性值 : static.f ...

  8. 比特(bit)和字节(Byte)

    比特(bit)和字节(Byte) 基础的内容就不说了,这里是一个小的学习笔记 比特和字节的写法差异与应用场景 标准的写法中,正如标题中写的那样,是通过大小写来区分比特和字节的:比特的b应该是小写,而字 ...

  9. centos安装配置LAMP,https,fastcgi

    Centos7 配置LAMP+fastcgi(Centos7.2+php7.0+mariadb+httpd)   环境:阿里云centos7.3 一.安装并配置数据库 1.安装数据库 #yum ins ...

  10. groovy程序设计

    /********* * groovy中Object类型存在隐式转换 可以不必使用as强转 */ Object munber = 9.343444 def number1 = 2 println mu ...