服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Java教程 - springboot 2.0 mybatis mapper-locations扫描多个路径的实现

springboot 2.0 mybatis mapper-locations扫描多个路径的实现

2021-10-27 10:17躁动的青年 Java教程

这篇文章主要介绍了springboot 2.0 mybatis mapper-locations扫描多个路径的实现方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

springboot 2.0 mybatis mapper-locations扫描多个路径

mapper-locations扫描多个路径,中间以,分开,

如果mapper.xml在源码包下,配置成classpath*开头比较好使

?
1
2
3
4
5
6
7
8
9
10
mybatis:
  mapper-locations: classpath*:mapper/*.xml,classpath*:com/urthink/upfs/**/*Mapper.xml
  type-aliases-package: com.urthink.upfs.springbootmybatis.entity
  #IDENTITY: MYSQL #取回主键的方式
  #notEmpty: false #insertupdate中,是否判断字符串类型!=''
  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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<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>

以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/haveqing/article/details/86624055

延伸 · 阅读

精彩推荐