多语言展示
当前在线:568今日阅读:75今日分享:44

SpringBoot项目如何集成依赖Mybatis

SpringBoot项目要如何集成依赖Mybatis呢,请跟着小编按以下步骤操作
方法/步骤
2

打开你的pom.xml文件,定位的依赖的配置部分,然后加入以下依赖,这是依赖mybatis框架      org.mybatis.spring.boot     mybatis-spring-boot-starter     1.1.1 

3

接着再加入以下依赖,这是指定mybatis框架的实现技术为mysql数据库,这里不需要配置具体数据库的版本.      mysql     mysql-connector-java 

4

在resource目录下创建一个application.yml文件,在里面配置数据库的连接信息

5

如图,根据你的实际信息按以下格式填写数据库的连接信息. spring:   datasource:     driver-class-name: com.mysql.jdbc.Driver     url: jdbc:mysql://127.0.0.1:3306/test?useunicode=true&characterEncoding=utf8     username: root     password: rood

6

接着要告诉springboot你的Mybatis映射关系配置在哪里,就是在yml中写入以下配置:mybatis:   type-aliases-package: com.gyf.domain   mapper-locations: classpath:mapper/*Mapper.xml

7

接下去就是创建domain包和mapper包,然后写实体类,接口和映射的Mapper.xml,这一块开始就已经是属于mybatis的内容的,在springboot中集成mybatis的部分已经完成了.

推荐信息