springboot-mybatis 配置详解
来源:互联网 发布:上海数据交易中心工资 编辑:程序博客网 时间:2024/05/17 04:59
1.pom 添加 Mybatis 依赖
1
2
3
4
5
6
<!-- Spring Boot Mybatis 依赖 -->
<dependency>
<groupId>org.mybatis.spring.boot<
/groupId
>
<artifactId>mybatis-spring-boot-starter<
/artifactId
>
<version>${mybatis-spring-boot}<
/version
>
<
/dependency
>
mybatis-spring-boot-starter 工程依赖如图:
2.在 application.properties 应用配置文件,增加 Mybatis 相关配置
1
2
3
## Mybatis 配置
mybatis.typeAliasesPackage=org.spring.springboot.domain
mybatis.mapperLocations=classpath:mapper/*.xml
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接口类
阅读全文
0 0
- springboot-mybatis 配置详解
- springboot中使用Mybatis注解配置详解
- springboot mybatis druid配置
- SpringBoot MyBatis基础配置
- Springboot 配置mybatis
- SpringBoot多数据源及MyBatis配置详解
- springboot+spring+springmvc+mybatis详解
- MyBatis springboot gradle 开发配置
- 【2】SpringBoot的MyBatis配置
- SpringBoot学习(3) 配置MyBatis
- springboot+mybatis手动配置数据源
- springboot 配置详解
- Springboot 配置详解
- SpringBoot DataSource配置详解
- Springboot 外置配置详解
- 【SpringBoot系列】二:SpringBoot配置详解
- SpringBoot多数据源的配置(SpringBoot+MyBatis)
- SpringBoot、MyBatis配置多数据源
- css3 flex属性flex-grow、flex-shrink、flex-basis学习笔记
- 字符串拷贝函数memcpy和strncpy以及snprintf 的性能比较
- hdoj 5952 Counting Cliques
- 归并排序算法
- js获取当前时间为整点,没有时分秒
- springboot-mybatis 配置详解
- 8.21 问题 D: 最短路径问题问题 D: 最短路径问题
- SQL语言概述
- 配置nginx实现跨域
- 8月21日总结
- 应届生面试问题
- 关于tinker 热修复的多渠道打包方式
- nodemcu开发
- ITSM Master——“IT界的EMBA”