1. 程式人生 > >spring boot之mybatis配置

spring boot之mybatis配置

nbsp ring 語句 ase result lazy div ica sets

配置在application.yml文件中

mybatis-plus:
  # 如果是放在src/main/java目錄下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
  mapper-locations: classpath:/com/bonc/flsz/**/mapping/*.xml
  #實體掃描,多個package用逗號或者分號分隔
  typeAliasesPackage: com.bonc.flsz.*.model
  global-config:
    #主鍵類型  0:"數據庫ID自增", 1:"用戶輸入ID",2:"全局唯一ID (數字類型唯一ID)", 3:"全局唯一ID UUID";
    id-type: 1
    #字段策略 0:"忽略判斷",1:"非 NULL 判斷"),2:"非空判斷"
    field-strategy: 2
    #駝峰下劃線轉換
    db-column-underline: true
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: true #配置的緩存的全局開關
    lazyLoadingEnabled: true #延時加載的開關
    multipleResultSetsEnabled: true #開啟的話,延時加載一個屬性時會加載該對象全部屬性,否則按需加載屬性
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印sql語句,調試用

pom裏的配置

在<build>中

<resources>
<resource>
<directory>src/main/resources</directory>
</resource>

<resource>
<directory>src/main/java</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>

spring boot之mybatis配置