Spring+Mybatis的applicationContext.xml配置文件

智慧并不产生于学历,而是来自对于知识的终生不懈的追求。这篇文章主要讲述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配置文件】 
 


    推荐阅读