springboot mybatis搭建
非常easy直接写,没有搭建成分
1、目录

2、
@RestController
public class UserController {
@RequestMapping("/hello")
public String index() {
return "Hello World";
} @Autowired
UserService userService; @RequestMapping(value = "/list", method = RequestMethod.GET)
public List<User> getAccounts() {
return userService.getUserList();
}
}
3、
@Mapper
public interface UserMapper { @Select("SELECT * FROM tb_user WHERE id = #{id}")
User getUserById(Integer id); @Select("SELECT * FROM tb_user")
public List<User> getUserList(); }
4、
@Service
public class UserService {
@Autowired
private UserMapper userMapper; public List<User> getUserList() {
return userMapper.getUserList();
}
}
6、
public class User {
private int id;
private String username;
private int age;
public User(int id, String username, int age) {
this.id = id;
this.username = username;
this.age = age;
}
public User(Long id, String username, Long age) {
this.id = Math.toIntExact(id);
this.username = username;
this.age = Math.toIntExact(age);
}
//不知道为啥报错,就按照提示来呗
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
7、
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
springboot mybatis搭建的更多相关文章
- springboot +mybatis 搭建完整项目
springboot + mybatis搭建完整项目 1.springboot整合mybatis注解版 转:https://blog.csdn.net/u013187139/article/detai ...
- 使用idea+springboot+Mybatis搭建web项目
使用idea+springboot+Mybatis搭建web项目 springboot的优势之一就是快速搭建项目,省去了自己导入jar包和配置xml的时间,使用非常方便. 1.创建项目project, ...
- idea+springboot+Mybatis搭建web项目
使用idea+springboot+Mybatis搭建一个简单的web项目. 首先新建一个项目: 在这里选择Maven项目也可以,但是IDEA为我们提供了一种更方便快捷的创建方法,即Spring In ...
- springboot+mybatis搭建web项目
使用idea+springboot+Mybatis搭建一个简单的web项目. 首先新建一个项目: 在这里选择Maven项目也可以,但是IDEA为我们提供了一种更方便快捷的创建方法,即Spring In ...
- SpringBoot+ Mybatis 搭建
spring boot+mybatis整合 LZ今天自己搭建了下Spring boot+Mybatis,比原来的Spring+SpringMVC+Mybatis简单好多.其实只用Spring bo ...
- 基于IDEA采用springboot+Mybatis搭建ssm框架简单demo项目的搭建配置流程
一.通过对比可以原始SSM搭建流程,spring boot省去了大量的配置,极大提高了开发者的效率.原始SSM框架搭建流程见博客: https://www.cnblogs.com/No2-explor ...
- SpringBoot + Mybatis搭建完整的项目架构
准备工作: Java开发环境 已安装 springboot 插件(STS)的 Eclipse MySQL服务 一. 创建 springboot 项目 1. 打开Eclipse --> 左上角 ...
- 基于SpringBoot+Mybatis+MySQL5.7的轻语音乐网
一个基于SpringBoot+Mybatis+MySQL5.7的轻语音乐网站项目 1.主要用到的技术: 使用maven进行项目构建 使用Springboot+Mybatis搭建整个系统 使用ajax连 ...
- 基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建
基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建 前言 最近做回后台开发,重新抓起以前学过的SSM(Spring+Sp ...
随机推荐
- Shader 入门笔记(二) CPU和GPU之间的通信,渲染流水线
渲染流水线 1)应用阶段(CPU处理) 首先,准备好场景数据(摄像机位置,视锥体,模型和光源等) 接着,做粗粒度剔除工作. 最后,设置好每个模型的渲染状态(使用的材质,纹理,shader等) 这一阶段 ...
- sql server 临时表(中) Tempdb监控
一. 监控概述 Tempdb库空间使用的一大特点,是只有一部分对象,例如用户创建的临时表.table变量等,可以用sys.allocation_units和sys.partitions这样的管理视图 ...
- docker~在centos容器中安装新程序
上一篇我们使用了阿里加速器安装了centos镜像,然后创建了一个新容器,运行了这个镜像,这一讲我们来为这个镜像添加一些应用程序,然后再保存容器,push容器到仓储,大家就可以直接pull我生产的容器了 ...
- 一文读懂MapReduce
Hadoop解决大规模数据分布式计算的方案是MapReduce.MapReduce既是一个编程模型,又是一个计算框架.也就是说,开发人员必须基于MapReduce编程模型进行编程开发,然后将程序通过M ...
- Java虚拟机详解----JVM内存结构
http://www.cnblogs.com/smyhvae/p/4748392.htm 主要内容如下: JVM启动流程 JVM基本结构 内存模型 编译和解释运行的概念 一.JVM启动流程: JVM启 ...
- 详解 Symbol 类型
ES5 的对象属性名都是字符串,这容易造成属性名的冲突.比如,你使用了一个他人提供的对象,但又想为这个对象添加新的方法(mixin 模式),新方法的名字就有可能与现有方法产生冲突.如果有一种机制,保证 ...
- logback配置信息
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true&q ...
- 痞子衡嵌入式:ARM Cortex-M内核那些事(3)- 功能模块
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是ARM Cortex-M功能模块. ARM Cortex-M处理器家族发展至今(2016),已有5代产品,分别是CM0/CM0+.CM1 ...
- vim编辑器详解(week1_day3)--技术流ken
vi编辑器 作用:编辑文本文件中的内容的工具 命令历史 末行模式中,以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 v ...
- Linux学习笔记之MySql的安装(CentOS)
一.移除mariadb 由于CentOS默认安装了mariadb,所以在安装MySql之前先移除mariadb,使用命令:yum remove mariadb-libs.x86_64,如下图所示: 二 ...