最全三大框架整合(使用映射)——applicationContext.xml里面的配置

     applicationContext.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"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-3.1.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" default-autowire="byName"><!-- 配置数据源 --><bean id="config" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><list><value>classpath:jdbc.properties</value></list></property></bean><!-- dataSource --><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="url" value="${jdbc.url}"></property><property name="driverClassName" value="${jdbc.driver}"></property><property name="username" value="${jdbc.username}"></property><property name="password" value="${jdbc.password}"></property></bean><!-- sessionFaction --><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource"></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop><prop key="hibernate.show_sql">true</prop><prop key="hibernate.format_sql">true</prop></props></property><property name="mappingDirectoryLocations"><list><value>classpath:org/entity</value></list></property></bean><!-- 事务 --><bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"></property></bean><!-- 增强 --><tx:advice id="txAdvice" transaction-manager="txManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED"/><tx:method name="save*" propagation="REQUIRED"/><tx:method name="update*" propagation="REQUIRED"/><tx:method name="del*" propagation="REQUIRED"/><tx:method name="get*" read-only="true"/><tx:method name="find*" read-only="true"/><tx:method name="query*" read-only="true"/><tx:method name="*"/></tx:attributes></tx:advice><aop:config><aop:pointcut id="mycut" expression="execution(* org.service..*.*(..))" /><aop:advisor advice-ref="txAdvice" pointcut-ref="mycut"/></aop:config> <!-- 引入dao层 --><import resource="applicationContext-dao.xml"/><!-- 引入service层 --><import resource="applicationContext-service.xml"/><!-- 引入action层 --><import resource="applicationContext-action.xml"/></beans>

     applicationContext-action.xml:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"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-3.1.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" default-autowire="byName"><bean id="deptAction" class="org.web.DeptAction"></bean></beans>

     applicationContext-dao.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd" default-autowire="byName"><!-- 配置DAO --><bean id="deptDao" class="org.dao.impl.DeptDaoImpl"><property name="sessionFactory" ref="sessionFactory"></property></bean></beans>

     applicationContext-service.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"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-3.1.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd" default-autowire="byName"><bean id="deptService" class="org.service.impl.DeptServiceImpl"></bean></beans>

 

 

 

 

 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/327410.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

win10系统用户访问ftp服务器被拒绝,关于windows2003下ftp用户名无法访问FTP服务器的问题...

关于windows 2003下建设FTP的步骤我不再详解&#xff0c;主要说两个我们经常出错的两个小问题&#xff0c;这两个小问题往往我们很容易忽视&#xff0c;使我们无法访问自己建立的FTP服务器。问题1&#xff1a;当我们建立一个FTP服务器选用“不隔离用户”选项并且选用不允许匿名…

Java动态代理之cglib

转载自 Java动态代理之cglib cglib是对jdk动态代理的补充&#xff0c;弥补了因没有接口的类生成代理类的缺失。 下面通过简单的例子学习一下cglib的使用&#xff0c;当然&#xff0c;要是用需要第三方的jar包&#xff0c;jar包自行下载。 业务类 public class BankService {…

SpringCloud Config 分布式配置

SpringCloud Config 分布式配置 Dalston.RELEASE Spring Cloud Config为分布式系统中的外部配置提供服务器和客户端支持。使用Config Server&#xff0c;您可以在所有环境中管理应用程序的外部属性。客户端和服务器上的概念映射与Spring Environment和PropertySource抽象相同…

.NET泛型初探

总所周知&#xff0c;.NET出现在.net framework 2.0&#xff0c;为什么要在2.0引入泛型那&#xff0c;因为微软在开始开发.net框架时并没有想过多个类型参数传输时对方法的重构&#xff0c;这样一来&#xff0c;开发人员就要面对传输多种类型的参数而不得以写多个方法&#xff…

最全三大框架整合(使用映射)——数据库资源文件jdbc.properties

jdbc.urljdbc:oracle:thin:127.0.0.1:1521:orcl jdbc.driveroracle.jdbc.OracleDriver jdbc.usernamepro jdbc.passwordpro

Java编程:Java的反射机制中的 getComponentType() 方法

转载自 Java编程&#xff1a;Java的反射机制中的 getComponentType() 方法 Java 中所有的类都继承自 Object&#xff0c;数组本身也是一个 Class&#xff0c;如果我们能够得到数据的 Class 对象&#xff0c;那么我们可以通过反射生成数组对象。 在Java的反射机制中&#xff0…

如何将idea自带的maven添加到环境变量

如何将idea自带的maven添加到环境变量 标签&#xff1a; maven idea 2018-07-10 阅读(3081) 想要通过命令形式在cmd操作IntelliJ IDEA自带的maven&#xff0c;那么就必须配置idea的maven环境变量。 下面以window 10 和 idea 2016.1为例&#xff1a; 第一步&#xff1a;找到…

三国志战略版360区S4服务器合并信息,三国志战略版pk赛季怎么转区?s4转区规则[多图]...

三国志战略版pk赛季是全新的开始&#xff0c;那么如果有的玩家想要转区的话&#xff0c;需要有哪些方法或者说是条件呢&#xff1f;下面来了解下&#xff01;三国志战略版pk赛季怎么转区&#xff1f;一、多久转服因为转服只有赛季快结束&#xff0c;也就是赛季末期才会开启&…

最全三大框架整合(使用映射)——struts.xml和web.xml配置

<?xml version"1.0" encoding"UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts><package …

SpringCloud(笔记)

简介 学习前提 熟练使用SpringBoot 微服务快速开发框架 了解过Dubbo Zookeeper 分布式基础 电脑配置内存不低于8G(我自己的是16G) 给大家看下多个服务跑起来后的内存开销图&#xff1a; 文章大纲 微服务架构面临的四个核心问题&#xff1f; 1.服务很多&#xff0c;客…

java身份证号码正则表达式校验(亲测可用) Java正则校验手机号

java身份证号码正则表达式校验&#xff08;亲测可用&#xff09; // 原文&#xff1a;https://blog.csdn.net/u011106915/article/details/76066985 public class IDUtils { public static boolean isIDNumber(String IDNumber) { if (IDNumber null || "&qu…

博客园官方 NuGet镜像上线试运行

为解决国内访问NuGet服务器速度不稳定的问题&#xff0c;我们用阿里云服务器搭建了一个NuGet镜像&#xff0c;目前已上线试运行。 使用NuGet镜像源的方法如下&#xff1a; 1&#xff09;NuGet镜像源地址&#xff1a;https://nuget.cnblogs.com/v3/index.json 2&#xff09;在Nu…

django ajax 简书,Django_ajax

一、Ajax通过jquery调用ajax前端三步&#xff0c;地址&#xff0c;类型&#xff0c;传值后台一步&#xff0c;success接受调用$.ajax({#传递地址url:/test_ajax,# 传递类型type:GET,#传递给后台的数据data:{user:root,pwd:123},#成功后从后台返回的数据success:function (data)…

Java synchronized 中的while 和 notifyAll

转载自 Java synchronized 中的while 和 notifyAll 问题1 为什么是while 而不是if 大多数人都知道常见的使用synchronized代码: synchronized (obj) {while (check pass) {wait();}// do your business } 那么问题是为啥这里是while而不是if呢? 这个问题 我最开始也想了很…

Java并发编程:Lock

转载自 Java并发编程&#xff1a;Lock 一.synchronized的缺陷 synchronized是java中的一个关键字&#xff0c;也就是说是Java语言内置的特性。那么为什么会出现Lock呢&#xff1f; 在上面一篇文章中&#xff0c;我们了解到如果一个代码块被synchronized修饰了&#xff0c;当一个…

docker下安装nacos 并使用mysql数据库

没做出来 腾讯云 有机会用虚拟机试试 参考资料 https://www.e-learn.cn/content/java/2357340 https://blog.csdn.net/xieqing_xq/article/details/105458887 重点 https://www.cnblogs.com/liushuchen/p/12488366.html 重点 http://122.51.187.132:8845/nacos/#/c…

tcp协议中的长连接和短连接服务器,谈谈HTTP协议中的短轮询、长轮询、长连接和短链接...

undefined在之前总结 WebSocket 的时候就已经提到过短长轮询了~~今天看公众号文章&#xff0c;又把长短连接引进来一起分析。感觉这种总结很棒&#xff0c;那么我们一起看看呗长短连接听说长短连接的话&#xff0c;应该都是这一句吧:HTTP1.0 协议不支持连接&#xff0c;从 HTTP…

javaMai+Springl实现给QQ邮箱发邮件(带附件,html格式)

以前的时候想着java发邮件很简单&#xff0c;因为当时使用的是outlook实现的&#xff0c;有兴趣的可以去看看之前的两篇博客文章&#xff0c;1.使用java底层实现邮件的发送&#xff08;含测试&#xff0c;源码&#xff09; 和 2.使用Spring实现邮件的发送&#xff08;含测试&…

分析开源项目

手把手教你分析开源项目 不知道代码怎么来的&#xff1f; 代码跑不起来&#xff1f; 项目对自己有帮助&#xff0c;不会模块化分析&#xff1f; 任何一个开源项目&#xff0c;都可以让自己得到提升&#xff01; 这里以 EL-ADMIN 为例https://el-admin.vip/ 1、观察开源项目…

Hangfire项目实践分享

项目中使用Hangfire已经快一年了&#xff0c;期间经历过很多次的试错及升级优化&#xff0c;才达到现在的稳定效果。趁最近不是太忙&#xff0c;自己在github上做了个案列&#xff0c;也是拿来跟大家分享下&#xff0c;案例是从项目里剥离出来的&#xff0c;有兴趣的可以访问 这…