springboot微服务搭建(一):整合mybatis配置(第一种方式)
来源:互联网 发布:人工智能的危害英文 编辑:程序博客网 时间:2024/05/16 14:40
现在看网上springboot集成mybatis有两种方式:第一种是使用maven的mybatis的依赖,填写配置文件;第二种是采用spring-mybatis的配置。
第一种,在已有的springboot项目的pom文件中加入
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version></dependency><dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version></dependency>然后在application.properties中添加
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/testspring.datasource.username=rootspring.datasource.password=spring.datasource.driver-class-name=com.mysql.jdbc.Drivermybatis.typeAliasesPackage=com.main.db.modelmybatis.mapperLocations=classpath:com/main/db/**/*Mapper.xmlspringboot会按照spring.datasource自动去匹配各种属性。mybatis.typeAliasesPackage扫描实体类位置,mybatis.mapperLocations扫描mybatis的xml文件。
然后在启动文件中加入
@MapperScan("com.main.db.dao")//扫描dao
用于扫描mybatis的接口。在mybatis的mapper文件加入@Mapper注解也可以,但是会增加工作量。
至此,第一种方式配置完毕。properties文件中还可以加入许多其他的配置,相信百度可以找到。其他的配置也没研究过。
阅读全文
0 0
- springboot微服务搭建(一):整合mybatis配置(第一种方式)
- springboot微服务搭建(一):搭建springboot框架
- SpringBoot搭建微服务(一)HelloWorld!
- springboot整合mybatis方式一
- SpringBoot~整合mybatis+微服务注册
- SpringBoot~整合mybatis+微服务注册
- SpringBoot构建微服务实战 之 整合Mybatis(一)
- springboot整合mybatis xml方式配置SQL
- SpringBoot+MyBatis整合——方式一(不使用starter)
- springboot搭建web(整合mybatis)(四)
- SpringBoot微服务的https配置方法(即微信小程序后台服务搭建解决方案)
- SpringBoot(五):SpringBoot整合MyBatis
- SpringBoot整合Mybatis(二)
- SpringBoot搭建微服务(二)实现MVC
- mybatis与spring整合(方式一)
- SpringBoot集成MyBatis(微服务)
- springBoot(四)整合之MyBatis整合
- 项目结构搭建【springboot mybatis个人博客系统(一)】
- PHP 程序员学数据结构与算法之《栈》
- 【转】windows 新版xgboost Python包安装教程 win10 64
- Android 获取OnItemClick事件中组件的内容
- ECSHOP的安全检测代码
- Recyclerview adapter.notify几个方法内存占用分析
- springboot微服务搭建(一):整合mybatis配置(第一种方式)
- 双十一,几何画板加入购物车了吗?
- 使用Thinkphp解决group和count一起使用的问题
- React 16.0中的新特性——portal及其注意点
- MaterialID 和 DrawCall
- linux dumpe2fs命令
- Google gflags 的使用
- 成为一名合格软件工程师的7点建议
- 搭建邮件服务器,过程非常简单