最全三大框架整合(使用映射)——applicationContext.xml里面的配置
2023-09-14 08:57:40 时间
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: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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://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"?>
<beans
xmlns="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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://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"?>
<beans
xmlns="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"?>
<beans
xmlns="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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://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>
相关文章
- JavaWeb_(Struts2框架)Log4j的配置以及解决中文乱码
- Spring Boot使用嵌入式容器,那怎么配置自定义Filter呢
- 【Idea】idea中spring框架配置文件,无法自动提示spring配置
- 戴尔Optiplex 3050 Micro(MFF)黑苹果安装BIOS配置和安装注意事项
- jekins构建通知邮件配置及邮件附件设置,jenkins构建通知邮件没有RF的log和report文件
- iOS网络编程--ASIHTTPRequest框架安装和配置-图文解说
- Nginx 环境配置 CodeIgniter 框架
- CodeIgniter框架配置
- 【网址收藏】dubbo特新概念及特性、环境搭建、dubbo-monitor安装、rpc原理以及dubbo原理:框架设计、启动解析&加载配置信息、服务暴露、服务引用及调用
- Centos CA自签证书服务器及自签证书配置手册
- ASP.NET Core 6框架揭秘实例演示[09]:将配置绑定为对象
- [ASP.NET Core 3框架揭秘] Options[7]: 与配置系统的整合
- [ASP.NET Core 3框架揭秘] 配置[7]:多样化的配置源[中篇]
- [Link]Flume NG 简介及配置实战
- Atitit 项目源码的架构,框架,配置与环境说明模板 规范 标准化
- dobbo 服务配置详解(解决超时重试问题)
- L2TP LAC initial 配置与安全策略
- MyBatis 源代码阅读笔记 1 基于XML配置的代码编写 mybatis-config.xml
- mysql的事务是什么 mybatis框架中的事务配置 mybatis中的自动提交事务和手动提交事务 深入理解mybatis事务源码 通过对象的地址来理解mysbaits中的会话 对象的首地址
- tp框架中的一些疑点知识--cookie和session的配置
- 华为运营商级路由器配置示例 | 跨域L3VdPdNdv4 over SRv6 TE Policy
- 通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术
- detectron2(目标检测框架)无死角玩转-03:配置config解析-实时更新
- 基于JAVA实现的WEB端UI自动化 - WebDriver框架篇 - ant使用 - ant安装、环境变量配置、ant实例及运行Ant Build 出现问题的解决方法