SpringBoot 整合Mybatis操作数据库
1.引入依赖:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
2.application.properties
#DB Configation
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/springboot?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
# JPAConfiguration
spring.jpa.database=mysql
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true spring.freemarker.suffix=.ftl
或application.yml
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springboot?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
username: root
password: root
jpa:
database: mysql
show-sql: true
generate-ddl: true
freemarker:
suffix: .ftl
3.在SpringBoot上增加启动类
@SpringBootApplication
@MapperScan(basePackages = "com.feiyu.user.dao")
public class JpaApplication { public static void main(String[] args) {
SpringApplication.run(JpaApplication.class, args);
} }
即可正常使用
SpringBoot 整合Mybatis操作数据库的更多相关文章
- kotlin + springboot整合mybatis操作mysql数据库及单元测试
项目mybatis操作数据库参考: http://how2j.cn/k/springboot/springboot-mybatis/1649.html?p=78908 junit对controller ...
- SpringBoot:4.SpringBoot整合Mybatis实现数据库访问
在公司项目开发中,使用Mybatis居多.在 SpringBoot:3.SpringBoot使用Spring-data-jpa实现数据库访问 中,这种jpa风格的把sql语句和java代码放到一起,总 ...
- spring-boot-route(八)整合mybatis操作数据库
MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射.MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集.MyBatis 可以使用简单的 XML ...
- 小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_3-1.整合Mybatis访问数据库和阿里巴巴数据源
笔记 1.整合Mybatis访问数据库和阿里巴巴数据源 简介:整合mysql 加入mybatis依赖,和加入alibaba druid数据源 1.加入依赖(可以用 http://start.s ...
- SpringBoot整合Mybatis对单表的增、删、改、查操作
一.目标 SpringBoot整合Mybatis对单表的增.删.改.查操作 二.开发工具及项目环境 IDE: IntelliJ IDEA 2019.3 SQL:Navicat for MySQL 三. ...
- SpringBoot整合mybatis、shiro、redis实现基于数据库的细粒度动态权限管理系统实例
1.前言 本文主要介绍使用SpringBoot与shiro实现基于数据库的细粒度动态权限管理系统实例. 使用技术:SpringBoot.mybatis.shiro.thymeleaf.pagehelp ...
- springboot整合mybatis连接mysql数据库出现SQLException异常
在springboot整合mybatis连接数据库的时候,项目中遇到一个SQLException,我检查了properties配置文件,看数据源有没有配错,检查有没有打错字,在数据库中把sql语句查询 ...
- springboot学习-jdbc操作数据库--yml注意事项--controller接受参数以及参数校验--异常统一管理以及aop的使用---整合mybatis---swagger2构建api文档---jpa访问数据库及page进行分页---整合redis---定时任务
springboot学习-jdbc操作数据库--yml注意事项--controller接受参数以及参数校验-- 异常统一管理以及aop的使用---整合mybatis---swagger2构建api文档 ...
- SpringBoot整合mybatis使用pageHelper插件进行分页操作
SpringBoot整合mybatis分页操作 SpringBoot整合Mybatis进行分页操作,这里需要使用Mybatis的分页插件:pageHelper, 关于pageHelper的介绍,请查看 ...
随机推荐
- Django—常见问题解决
让Django项目运行允许外部访问 1.将python manage.py runserver 改为 python manage.py runserver 0.0.0.0:80 或者 python m ...
- liteos C++支持(十七)
1 概述 1.1 基本概念 C++作为目前使用最广泛的编程语言之一,支持类.封装.重载等特性,是在C语言基础上开发的一种面向对象的编程语言. 1.2 运作机制 STL(Standard Templat ...
- cin.get()解密
最近在使用cin.get()函数时遇到了一个迷惑行为,现已解开. 一.cin.get()的用法 char ch; ch = cin.get(); //第1种用法 cin.get(ch); //第2种用 ...
- 无序数组中用 快速排序的分治思想 寻找第k大元素
#include <stdio.h> int *ga; int galen; void print_a(){ ; i < galen; i++){ printf("%d & ...
- PHP连接Navicat For Mysql并取得数据
Navicat For Mysql中新建数据库 数据库中新建表 保存表 表中添加数据 打开ide,输入以下php代码,使用localhost打开该php文件 <?php // ip地址.用户名. ...
- luoguP4719 【模板】动态 DP
题意 我理解的动态DP: 发现DP可以写成矩阵的形式,因此用数据结构维护矩阵乘积. 对于这道题,显然有DP: \(f_{x,0/1}\)表示\(x\)的子树中,x选/不选的最大点独立集. \(f_{x ...
- Python进阶-XVIV 类的内置方法:__str__ 、__repr__、析构函数(__del__)、双下的call,eq,new,hash 以及item相关的三个方法
类的内置方法 它与内置函数有紧密的联系,有的内置函数就是调用的内置方法. 在顶级父类obj中有: 两个双下方法 obj.__str__ str(obj) obj.__repr__ repr(obj) ...
- Fontconfig error: Cannot load config file "infinality/conf.d"
reference: https://forums.gentoo.org/viewtopic-t-1079210-start-0.html resolved with following method ...
- C#中List<T>转DataTable
通过查询出来的类的集合的属性集合生成数据行,并通过属性获取每一个实体的指定属性的指定值
- POJ3685Matrix(二分套二分)
传送门 题目大意:N*N的矩阵,a[i][j]=i*i+100000*i+j*j-100000*j+i*j,求矩阵中第K小. N<=5*10^4 题解: 打个表,发现每一列从上往下单调递增. 在 ...