博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring +springmvc+mybatis组合applicationContext.xml文件配置
阅读量:6891 次
发布时间:2019-06-27

本文共 2361 字,大约阅读时间需要 7 分钟。

<?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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.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/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<!--读取配置文件 -->
<bean class=" org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:datasource.properties"></property>
</bean>
<!-- 配置数据源-->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</bean>
<!--配置mybatis里的sessionFactroy -->
<bean id="sessionFactory" class=" org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean>

<!--映射接口扫描mapper包下的所有xml文件 mapper是个包名 应该是在main测试的时候才使用--->

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<property name="basePackage" value="com.liu.mapper"></property>
</bean>

<!--配置声明试事务 配置事务管理器 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--配置事务通知 -->
<tx:advice id="txadvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!--配置切面 必须要有空格 *空格 ssmy 否则会报错--> 
<aop:config>
<aop:pointcut expression="execcution(*空格 ssmy.service.impl.*.*(..))" id="pointcut"/>
<aop:advisor advice-ref="txadvice" pointcut-ref="pointcut"/>
</aop:config>
<context:component-scan base-package="ssmy"/>
</beans>

转载于:https://www.cnblogs.com/JesseCary/p/5790254.html

你可能感兴趣的文章
java 同步锁 synchronized 死锁 lock锁 jion 线程结束
查看>>
jsf开发心得(3)-jsf应用中css运用背景图片显示不了的问题
查看>>
IOS UIAlertController 弹出框中添加视图(例如日期选择器等等)
查看>>
ubuntu 12.04 开启root
查看>>
WAR包制作
查看>>
XSS
查看>>
Java 线程学习
查看>>
JDK容器学习之List: CopyOnWriteArrayList,ArrayList,LinkedList对比
查看>>
acl_cpp 编程之 xml 流式解析与创建
查看>>
嫁给程序员的十大好处
查看>>
CentOS-6.4下安装VirtualBox记
查看>>
linux三剑客之awk
查看>>
28BYJ-48步进电机迁移转变精度与深化剖析
查看>>
apache与PHP结合,apache默认虚拟机
查看>>
基于域的无线安全认证方案
查看>>
Android平板开发永久实现全屏的方法
查看>>
windows远程连接失败的原因
查看>>
我的友情链接
查看>>
Centos下邮件服务器(postfix)的配置(一)
查看>>
Thread类常用方法
查看>>