您的位置:首页 > 编程语言 > Java开发

springboot-mybatis 配置详解

2017-08-21 16:47 337 查看
1.pom 添加 Mybatis 依赖

mybatis.typeAliasesPackage 配置为 org.spring.springboot.domain,指向实体类包路径。mybatis.mapperLocations 配置为 classpath 路径下 mapper 包下,* 代表会扫描所有 xml 文件。

mybatis 其他配置相关详解如下:

mybatis.config = mybatis 配置文件名称
mybatis.mapperLocations = mapper xml 文件地址

mybatis.typeAliasesPackage = 实体类包路径
mybatis.typeHandlersPackage = type handlers 处理器包路径
mybatis.check-config-location = 检查 mybatis 配置是否存在,一般命名为 mybatis-config.xml

mybatis.executorType = 执行模式。默认是 SIMPLE

3.在 Application 应用启动类添加注解 MapperScan

mapper 接口类扫描包配置注解 MapperScan :用这个注解可以注册 Mybatis mapper 接口类。

4.添加相应的domain类、Dao mapper接口类

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐