【问题标题】:How to config mybatis mapper xml files in Spring boot's application.yml如何在 Spring boot 的 application.yml 中配置 mybatis mapper xml 文件
【发布时间】:2016-06-07 20:33:50
【问题描述】:

我是 Spring Boot 的新手,我想让我的 Spring Boot 应用程序与 mybatis 和 mysql 数据库集成。 我使用生成器生成实体、映射器接口和映射器 xml 文件。而且我还使用@MapperScan 注释告诉应用程序如何找到映射器,我的 application.yml 如下所示:

spring:
  datasource:
    username: root
    password:
    url: jdbc:mysql://localhost:3306/bidding
    driver-class-name: com.mysql.jdbc.Driver

mybatis:
  mapperLocations: classpath:mapping/*.xml

但是当我使用命令“mvn spring-boot:run”运行应用程序时,它总是给我错误消息“无效绑定语句(未找到)”。

我的代码中是否遗漏了什么?

【问题讨论】:

    标签: spring-boot mybatis spring-mybatis


    【解决方案1】:

    mybatis接口和xml的映射有问题。

    1. 检查接口和xml的包,应该是同一个包
    2. 检查xml中的命名空间和xml的包,它们应该是相同的路径

    【讨论】:

    • 同一个包,请解释一下
    最近更新 更多