springboot 整合druid和mybatis
Shrio+Mybatis+Druid
1.导入相关依赖包
2.在配置文件配置数据源
3.pojo对应实体类和mapper目录下的接口UserMapper
(3.使用注解版)

package com.lian.mapper;
import com.lian.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository; import java.util.List; @Repository
@Mapper
public interface UserMapper { @Select("select * from user")
List<User> getUsers();
// 通过id查询
@Select("select * from user where id=#{332}")
User getUserById(@Param("332") int id);
@Insert("insert into user(id,name,pwd) values(#{id},#{name},#{pwd})")
int addUser(User user);
@Update("UPDATE USER set NAME=#{name},PWD=#{pwd} where id=#{id}")
int updateUser(User user);
@Delete("delete from user where id=#{id}")
int delUser(int id); }
4.在资源目录下新建UserMapper.xml

5.controller测试

总结:
在springboot整合mybatis(使用注解偷懒版)
1.下载依赖包:mybatis-spring-boot-starter
2.在配置文件properties或者yaml连接数据库
3.com.lian下新建mapper目录,在mapper目录下写接口
并且用注解的方式在接口上方写对应sql,注意点:记得在接口上方写注解@Repository和@Mapper
4.controller目录下写测试类,注意点:记得在mapper上方自动装配@Autowired
在springboot整合mybatis(使用xml文件)
1.下载依赖包:mybatis-spring-boot-starter
2.在配置文件properties或者yaml连接数据库
3.com.lian下新建mapper目录,在mapper目录下写接口
4.在资源目录下写xml配置文件
5.controller目录下写测试类,注意点:记得在mapper上方自动装配@Autowired
springboot 整合druid和mybatis的更多相关文章
- springboot整合druid、mybatis
目的: 1.springboot配置数据库连接池druid 测试druid中url监控 2.springboot整合mybatis 测试查删案例 3.springboot整合pagehelper sp ...
- SpringBoot:整合Druid、MyBatis
目录 简介 JDBC 导入依赖 连接数据库 CRUD操作 自定义数据源 DruidDataSource Druid 简介 配置数据源 配置 Druid 数据源监控 配置 Druid web 监控 fi ...
- SpringBoot第五集:整合Druid和MyBatis(2020最新最易懂)
SpringBoot第五集:整合Druid和MyBatis(2020最新最易懂) 1.SpringBoot整合Druid Druid是阿里巴巴的一个开源项目,是一个数据库连接池的实现,结合了C3P0. ...
- SpringBoot整合Redis、mybatis实战,封装RedisUtils工具类,redis缓存mybatis数据 附源码
创建SpringBoot项目 在线创建方式 网址:https://start.spring.io/ 然后创建Controller.Mapper.Service包 SpringBoot整合Redis 引 ...
- Springboot整合druid
目录 Springboot整合druid application.yml DruidConfig 数据监控地址:http://localhost:8080/druid Springboot整合drui ...
- SpringBoot整合Druid数据连接池
SpringBoot整合Druid数据连接池 Druid是什么? Druid是Alibaba开源的的数据库连接池.Druid能够提供强大的监控和扩展功能. 在哪里下载druid maven中央仓库: ...
- 【SpringBoot | Druid】SpringBoot整合Druid
SpringBoot整合Druid Druid是个十分强大的后端管理工具,具体的功能和用途请问阿里爸爸 1. 在pom.xml中导入包 <!-- alibaba 的druid数据库连接池 --& ...
- SpringBoot 整合jdbc和mybatis
摘要 该文章主要为记录如何在SpringBoot项目中整合JDBC和MyBatis,在整合中我会使用简单的用法和测试用例,毕竟该文章目的是为了整合,而不是教大家如何去使用.希望大家多多包涵. 通用配置 ...
- 003 SpringBoot整合SpringMVC、Mybatis 案例
1.不使用骨架创建一个maven工程 2.修改POM.xml文件 <?xml version="1.0" encoding="UTF-8"?> &l ...
- springboot整合druid和配置资源监控
1.添加依赖,在maven repository中搜索 <dependency> <groupId>com.alibaba</groupId> <artifa ...
随机推荐
- TSCTF-J 2022 WP
Re baby_xor 加密逻辑如上,密文动态调试,然后 Shift+E 导出密文[这样避免了手动获取] # encoding=utf-8 enc=[ 0x12, 0x00, 0x00, 0x00, ...
- Python常见加密解密算法
Python爬虫常见加密解密算法 url encode加密 简介:当url地址含有中文,或者参数有中文的时候,这个算是很正常了,但是把这样的url作为参数传递的时候(最常见的callback) ,需要 ...
- 操作系统笔记<1>
操作系统的概念 指控制和管理整个计算机系统的硬件和软件资源,并合理地组织调度计算机的工作和资源的分配 以提供给用户和其他软件方便的接口和环境 是计算机系统中最基本的系统软件 操作系统的功能 (系统资源 ...
- University of Toronto Faculty of Arts and Science MAT344– Final Assessment Combinatorics Instructors: Stanislav Balchev and Max Klambauer 19 August 2020
目录 随便找的一份测试题 T7 T9 T6 T5 solution to (a) solution to (b) solution to (c) solution to (d) T1 T2 T3 T4 ...
- Spring框架中都用到了哪些设计模式 ?
1.简单工厂模式 简单工厂模式的本质就是一个工厂类根据传入的参数,动态的决定实例化哪个类.Spring 中的 BeanFactory 就是简单工厂模式的体现,根据传入一个唯一的标识来获得 bean 对 ...
- Mybatis # 与 $ 符号区别
一.区别 1.不同点: 以#{}方式传入参数,预编译时,它会将sql中的#{}替换为?,然后编译sql时,会把值两端加上 双引号.有效防止sql注入,保证数据安全. sql注入:通过把SQL命令插入到 ...
- 我为什么推荐Nuxt3
我为什么推荐Nuxt3? 大家好,我今天想和你们分享一个非常棒的前端框架--Nuxt3.自从我接触了Nuxt3,我发现它在前端开发领域具有很多优点.我想逐一向你们介绍Nuxt3的优势,并向大家推荐一些 ...
- $\mathcal{Friends\,\,Of\,--Mathic}$
- node.js解决跨域方案
服务端 1.通过使用cors模块解决跨域问题 var express = require('express') , cors = require('cors') , app = express(); ...
- Carla 自动驾驶仿真平台的安装与配置指南
简介 Carla 是一款基于 Python 编写和 UE(虚幻引擎)的开源仿真器,用于模拟自动驾驶车辆在不同场景下的行为和决策.它提供了高度可定制和可扩展的驾驶环境,包括城市.高速公路和农村道路等.C ...