SpringBoot集成Mybatis

こ雲淡風輕ζ 提交于 2019-12-26 17:12:25

1 导入依赖

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>1.1.1</version>
</dependency>

2 配置mybatis

在application.yml中添加:

mybatis:
  mapper-locations: classpath:cn/xh/mapper/*Mapper.xml

3 配置Mapper接口扫描包

在主配置类(ApplicationConfig.java)中添加注解@MapperScan:

@SpringBootApplication
@MapperScan("cn.xh.web.controller.mapper")
public class ApplicationConfig {
   ...
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!