mybatis integrado (V)

xml manera integrada:

<? xml version = "1.0" encoding = "UTF-8"?> 
<habas xmlns = "http://www.springframework.org/schema/beans" 
    xmlns: xsi = "http://www.w3.org / / XMLSchema instancia 2001 "xmlns: p = "http://www.springframework.org/schema/p" 
    xmlns: tx = "http://www.springframework.org/schema/tx" xmlns: contexto =" http://www.springframework.org/schema/context " 
    xmlns: MVC = "http://www.springframework.org/schema/mvc" 
    xsi: schemaLocation =" http://www.springframework.org/schema/ habas http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
       http: // www.springframework.org/schema/tx http: //www.springframework.org / esquema / TX / primavera-TX-4.0.xsd 
       http: //www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd 
       http: // www.springframework.org/schema/mvc http: //www.springframework .org / esquema / MVC / primavera-mvc-4.0.xsd ">
        
<-使用注解驱动-> 
<- <context: anotación-config /> -> 
    <context: base-componente de exploración paquete = "com.example" /> 
    <! -数据库连接池-> 
    <bean id = "origen de datos" clase => "org.apache.commons.dbcp.BasicDataSource"  
        <property name = "driverClassName" value = "com .mysql.cj.jdbc.Driver"/>
        <nombre de propiedad = valor "url" = "jdbc : mysql: // localhost: 3306 / papel characterEncoding = UTF-8 & amp; useSSL = false & amp;serverTimezone = GMT% 2B8 & amp; allowPublicKeyRetrieval = true "/> 
        <property name = "nombre de usuario "value =" "/> root 
        <property name = "" value = "contraseña"/> 123456ABC 
        <property name = "" value = "maxActive 255"/> 
        <property name = "" value = "maxIdle 5"/> 
        <nombre de propiedad = valor "maxWait" = "10000" /> 
    </ bean> 

    <! -集成mybatis -> 
    <bean id = "SqlSessionFactory" clase = "org.mybatis.spring.SqlSessionFactoryBean "> 
        <property name =" dataSource" ref = "origen de datos"/> 
        <property name = "" value = "configLocation ruta de clases: /mybatis/mybatis-config.xml"/> 
    </ bean> 

    <! -配置数据源事务管理器-> 
    <bean id = "transactionManager" clase = "org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
        <property name ="El origen de datos "REF =" el origen de datos "/> 
    </ bean> 
    <! - crear una pluralidad de mapper en el paquete especificado generar la exploración automática el grano -> 
    <bean clase
        

= "org.mybatis.spring.mapper.MapperScannerConfigurer"> 
        <nombre de propiedad = valor "basePackage" = /> "com.example.dao" 
        <nombre de propiedad = valor "sqlSessionFactoryBeanName" = "SqlSessionFactory" /> 
        <! -指定标注才扫描成为Mapper -> 
        <nombre de propiedad = valor "annotationClass" = "org.springframework.stereotype.Repository" /> 
    </ bean> 


</ beans>

Supongo que te gusta

Origin www.cnblogs.com/xc-xinxue/p/12482231.html
Recomendado
Clasificación