springboot 2.0 mybatis mapper-locations掃描多個路徑的實現

springboot 2.0 mybatis mapper-locations掃描多個路徑

mapper-locations掃描多個路徑,中間以,分開,

如果mapper.xml在源碼包下,配置成classpath*開頭比較好使

mybatis:
  mapper-locations: classpath*:mapper/*.xml,classpath*:com/urthink/upfs/**/*Mapper.xml
  type-aliases-package: com.urthink.upfs.springbootmybatis.entity
  #IDENTITY: MYSQL #取回主鍵的方式
  #notEmpty: false #insert和update中,是否判斷字符串類型!=''
  configuration:
    #進行自動映射時,數據以下劃線命名,如數據庫返回的"order_address"命名字段是否映射為class的"orderAddress"字段。默認為false
    map-underscore-to-camel-case: true
    # 輸出SQL執行語句 (log4j2本身可以輸出sql語句)
    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #這種帶結果集

maven 打包源碼包下的資源文件,如xml

  <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <!-- <excludes>
                    <exclude>**/*.properties</exclude>
                    <exclude>**/*.xml</exclude>
                </excludes> -->
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

以上為個人經驗,希望能給大傢一個參考,也希望大傢多多支持WalkonNet。

推薦閱讀: