Radan小哥 2022-06-07 18:31 采纳率: 40%
浏览 466
已结题

mapperlocations=classpath:mapper/*.xml 报错,如何解决?

springboot整合mybatis时异常
问题描述
mybatis:
  mapper-locations: classpath:**/*.xml   #这个可以使用
 #mapper-locations: classpath:mappeer/*.xml #这个不行


相关配置文件信息
#datasource
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/javaee?serverTimezone=UTC
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver
##mybatis配置

mybatis:

  mapper-locations: classpath:**/*.xml
  #mapper映射文件
  type-aliases-package: com.example.pojo
  #设置别名

userMapper.xml 位置

src/main/resources/mapper/UserMapper.xml

我想要达到的结果

mybatis.mapper-locations= classpath:mapper/*.xml 如何和这样配置也是可以

  • 写回答

1条回答 默认 最新

  • Radan小哥 2022-06-07 18:52
    关注
    mapper-locations: classpath*:m*/*.xml 
    

    这个**/*.xml好像不能用 前面必须得有字母

    #  mapper-locations: classpath:mapper/*.xml 
    

    这个也可以,由于没有指定namespace(没注意看)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 6月15日
  • 已采纳回答 6月7日
  • 创建了问题 6月7日