美文网首页
mybatis的基本配置

mybatis的基本配置

作者: JiangCheng97 | 来源:发表于2020-02-05 22:14 被阅读0次

    application.yml

    spring:
      datasource:
        username: root
        password: 123456
        url: jdbc:mysql://192.168.0.113:3306/mybatis
        driver-class-name: com.mysql.cj.jdbc.Driver
        type: com.alibaba.druid.pool.DruidDataSource
        #    type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
        #    schema:
        #      - classpath:department.sql
        #    initialization-mode: always
    
        #   数据源其他配置
        initialSize: 5
        minIdle: 5
        maxActive: 20
        maxWait: 60000
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: SELECT 1 FROM DUAL
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        #   配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
        filters: stat,wall,slf4j
        maxPoolPreparedStatementPerConnectionSize: 20
        useGlobalDataSourceStat: true
        connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
    #    schema:
    #      - classpath:sql/department.sql
    #      - classpath:sql/employee.sql
    #    initialization-mode: always
    mybatis:
      #指定全局文件配置路径
      config-location: classpath:mybatis/mybatis-config.xml
      #指定sql映射文件配置路径
      mapper-locations: classpath:mybatis/mapper/*.xml
    
    

    mybatis-config.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration
            PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
        <settings>
            <setting name="mapUnderscoreToCamelCase" value="true"/>
        </settings>
    </configuration>
    

    相关文章

      网友评论

          本文标题:mybatis的基本配置

          本文链接:https://www.haomeiwen.com/subject/momexhtx.html