Implementation of spring boot 2.0 mybatis mapper locations scanning multiple paths

Time:2021-12-28

Springboot 2.0 mybatis mapper locations scans multiple paths

Mapper locations scans multiple paths, separated by,

If mapper XML is configured asclasspath*It works better at the beginning

mybatis:
  mapper-locations: classpath*:mapper/*.xml,classpath*:com/urthink/upfs/**/*Mapper.xml
  type-aliases-package: com.urthink.upfs.springbootmybatis.entity
  #Identity: how MySQL # retrieves the primary key
  #Notempty: false #insert and update, whether to judge the string type! = ''
  configuration:
    #During automatic mapping, the data is named with an underscore, such as whether the "order_address" named field returned by the database is mapped to the "orderaddress" field of class. The default is false
    map-underscore-to-camel-case: true
    #Output SQL execution statements (log4j2 itself can output SQL statements)
    #log-impl: org. apache. ibatis. logging. stdout. Stdoutimpl # is a result set with

Maven packages resource files under the source package, such as 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>

The above is my personal experience. I hope I can give you a reference, and I hope you can support developpaer.