智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述Spring+Mybatis的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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> < bean id="config" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"> < property name="locations"> < list> < value> classpath:database.properties< /value> < /list> < /property> < /bean> < !-- 1. 配置数据源 --> < bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> < property name="driverClassName"> < value> ${driver}< /value> < /property> < property name="url"> < value> ${url}< /value> < /property> < property name="username"> < value> ${user}< /value> < /property> < property name="password"> < value> ${password}< /value> < /property> < /bean> < !-- 2. 配置sqlsession --> < bean id="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean"> < property name="dataSource" ref="dataSource" /> < property name="configLocation" value="https://www.songbingjia.com/android/classpath:mybatis-config.xml" /> < /bean> < !-- 3. 配置Dao --> < bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> < property name="basePackage" value="https://www.songbingjia.com/android/com.dao" /> < /bean> < !-- 4. 配置serccvvice扫描注解 --> < context:annotation-config /> < context:component-scan base-package="com.service" /> < !-- 5.配置事务 --> < bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> < property name="dataSource" ref="dataSource" /> < /bean> < tx:annotation-driven transaction-manager="txManager"/> < /beans>
【Spring+Mybatis的applicationContext.xml配置文件】
推荐阅读
- Android BlueDroid(BlueDroid蓝牙开启过程init)
- 什么是量化()
- 每英寸的像素、点和线
- 数字图像直方图介绍
- JavaScript设计模式综合用法示例和指南
- 啥是网线交叉线接法?有啥好处?
- 安装系统 最好用的天地一键重装系统简介
- 暗网是啥?天地本文为你详解暗网的真面目
- 笔记本电脑选购注意事项