Mybaits整合Spring自动扫描 接口,Mybaits配置文件.xml文件和Dao实体类

1.转自:https://blog.csdn.net/u013802160/article/details/51815077

 1 xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:mvc="http://www.springframework.org/schema/mvc"
 6     xsi:schemaLocation="http://www.springframework.org/schema/beans    
 7                             http://www.springframework.org/schema/beans/spring-beans-3.1.xsd    
 8                             http://www.springframework.org/schema/context    
 9                             http://www.springframework.org/schema/context/spring-context-3.1.xsd    
10                             http://www.springframework.org/schema/mvc    
11                             http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
12 
13     
14     <context:component-scan base-package="com.goshop" />  
15 
16     
17     <bean id="propertyConfigurer"
18         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
19         <property name="location" value="classpath:jdbc.properties">property>
20     bean>
21 
22     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
23         destroy-method="close">
24         <property name="driverClassName" value="${driver}" />
25         <property name="url" value="${url}" />
26         <property name="username" value="${username}" />
27         <property name="password" value="${password}" />
28         
29         <property name="initialSize" value="${initialSize}">property>
30         
31         <property name="maxActive" value="${maxActive}">property>
32         
33         <property name="maxIdle" value="${maxIdle}">property>
34         
35         <property name="minIdle" value="${minIdle}">property>
36         
37         <property name="maxWait" value="${maxWait}">property>
38     bean>
39 
40     
41     <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
42         <property name="dataSource" ref="dataSource">property>
43         
      
      
44 45 <property name="mapperLocations" value="classpath:com/goshop/mapper/*.xml">property> 46 bean> 47 48 49 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 50 <property name="basePackage" value="com.goshop.dao" /> 51 <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory">property> 52 bean> 53 54 55 <bean id="transactionManager" 56 class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 57 <property name="dataSource" ref="dataSource" /> 58 bean> 59 60 beans>

 

2.

  
43         
      
       44

转载于:https://www.cnblogs.com/sharpest/p/6139500.html

你可能感兴趣的:(Mybaits整合Spring自动扫描 接口,Mybaits配置文件.xml文件和Dao实体类)