创建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. linux shadow文件格式弱口令解密

    shadow格式弱口令为linux弱口令,通过kali linux 终端 john --w=字典 加上shadow文件, 扫描完成之后通过john --show 加上shadow文件出结果

  2. 房地产大佬潘石屹推荐学Python编程,这本从0到1就够了

    潘石屹推荐学Python编程,很多人都不相信,他的微博真真切切. 连房地产都开始学Python了,因为要听懂机器,让机器为我所用. 再不学习Python真的晚了!!!! 如何学? 怎么学? 还是推荐高 ...

  3. GitHub从小白到熟悉<五>

    GitHub    主页 

  4. xargs、chattr命令

    一.xargs:将标准输入转化成命令行参数 用法:xargs [OPTION] ... COMMAND INITIAL-ARGS ...使用参数INITIAL-ARGS运行COMMAND,并从输入中读 ...

  5. 第一章 T-SQL查询和编程基础 T-SQL语言基础(2)

    T-SQL查询和编程基础 (2) 1.3 创建表和定义数据完整性 注意:表是属于架构,而架构又是属于数据库的 -- Create a database called testdb IF DB_ID(' ...

  6. Java APi 之 RMI远程方法调用

    一.什么是RPC RPC全称是remote procedure call,即远程过程调用.它是一种协议,用于从远程计算机上请求服务. 例如有两台服务器A和B,A上的应用想要调用B上应用的方法,但是他们 ...

  7. SQL 优化SQL查询

    摘至于:http://www.cnblogs.com/ATree/archive/2011/02/13/sql_optimize_1.html 1. 首先要搞明白什么叫执行计划? 执行计划是数据库根据 ...

  8. PHP7安装redis扩展

    PHP7安装redis扩展优秀开源项目:http://github.crmeb.net/u/liaofeiyum -y install git git clone https://github.com ...

  9. tornada-模板

    tornado模板 1.配置模板路径 (project/config.py) # coding=utf-8 import os BASE_DIRS = os.path.dirname(__file__ ...

  10. 小程序UI设计(2)-符合视觉规范-字体规范

    下图是微信小程序官方要求字体规范 根据此要求小程序设计工具定制了符合规范的组件.如下图 工具使用时,将左侧组件拖拽到设计区域即可.字体大小和颜色都是按照规范设置的.在使用时根据微信要求在不同位置摆放即 ...