非常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搭建的更多相关文章

  1. springboot +mybatis 搭建完整项目

    springboot + mybatis搭建完整项目 1.springboot整合mybatis注解版 转:https://blog.csdn.net/u013187139/article/detai ...

  2. 使用idea+springboot+Mybatis搭建web项目

    使用idea+springboot+Mybatis搭建web项目 springboot的优势之一就是快速搭建项目,省去了自己导入jar包和配置xml的时间,使用非常方便. 1.创建项目project, ...

  3. idea+springboot+Mybatis搭建web项目

    使用idea+springboot+Mybatis搭建一个简单的web项目. 首先新建一个项目: 在这里选择Maven项目也可以,但是IDEA为我们提供了一种更方便快捷的创建方法,即Spring In ...

  4. springboot+mybatis搭建web项目

    使用idea+springboot+Mybatis搭建一个简单的web项目. 首先新建一个项目: 在这里选择Maven项目也可以,但是IDEA为我们提供了一种更方便快捷的创建方法,即Spring In ...

  5. SpringBoot+ Mybatis 搭建

    spring boot+mybatis整合   LZ今天自己搭建了下Spring boot+Mybatis,比原来的Spring+SpringMVC+Mybatis简单好多.其实只用Spring bo ...

  6. 基于IDEA采用springboot+Mybatis搭建ssm框架简单demo项目的搭建配置流程

    一.通过对比可以原始SSM搭建流程,spring boot省去了大量的配置,极大提高了开发者的效率.原始SSM框架搭建流程见博客: https://www.cnblogs.com/No2-explor ...

  7. SpringBoot + Mybatis搭建完整的项目架构

    准备工作: Java开发环境 已安装 springboot 插件(STS)的 Eclipse MySQL服务  一. 创建 springboot 项目 1. 打开Eclipse  --> 左上角 ...

  8. 基于SpringBoot+Mybatis+MySQL5.7的轻语音乐网

    一个基于SpringBoot+Mybatis+MySQL5.7的轻语音乐网站项目 1.主要用到的技术: 使用maven进行项目构建 使用Springboot+Mybatis搭建整个系统 使用ajax连 ...

  9. 基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建

    基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建 前言 最近做回后台开发,重新抓起以前学过的SSM(Spring+Sp ...

随机推荐

  1. C#版 - Leetcode 201. 数字范围按位与(bitwise AND) - 题解

    C#版 - Leetcode 201. 数字范围按位与(bitwise AND) - 题解 在线提交: https://leetcode.com/problems/bitwise-and-of-num ...

  2. 如何使用Git提高研发团队工作效率?

    为什么使用Git 随着互联网时代的来临与发展,尤其分布式开发的大力引入,对于开发工程师来说,代码管理变成了头等难题.10多个人或者更多的成员的研发团队如何管理同一份代码,异地办公如何跟同事有效的维护同 ...

  3. 输入法设置,SublimeTest,putty掉线

    设置默认中文 在我们使用计算机中,如果输入法的默认语言是英文,那么我们操作起来会更加方便,那我们怎么设置呢??? 以Windows10为例 SublimeTest相关设置 SublimeTest出现乱 ...

  4. Docker 网络之进阶篇

    笔者在<Docker 基础 : 网络配置>一文中简单介绍了容器网络的基本用法,当时网络的基本使用方式还处于 --link 阶段.时过境迁,随着 docker 的快速发展,其网络架构也在不断 ...

  5. Spring基础系列-参数校验

    原创作品,可以转载,但是请标注出处地址:https://www.cnblogs.com/V1haoge/p/9953744.html Spring中使用参数校验 概述 ​ JSR 303中提出了Bea ...

  6. BlockingQueue 阻塞队列实现异步事件

    转载请注明出处:https://www.cnblogs.com/wenjunwei/p/10411444.html 前言 本文通过一个简单的例子,来展现如何使用阻塞队列(BlockingQueue)来 ...

  7. SpringBoot系列——Spring-Data-JPA(升级版)

    前言 在上篇博客中:SpringBoot系列——Spring-Data-JPA:https://www.cnblogs.com/huanzi-qch/p/9970545.html,我们实现了单表的基础 ...

  8. 【深度学习系列】用PaddlePaddle和Tensorflow实现经典CNN网络AlexNet

    上周我们用PaddlePaddle和Tensorflow实现了图像分类,分别用自己手写的一个简单的CNN网络simple_cnn和LeNet-5的CNN网络识别cifar-10数据集.在上周的实验表现 ...

  9. 一统江湖的大前端(2)—— Mock.js + Node.js 如何与后端潇洒分手

    <一统江湖的大前端>系列是自己的前端学习笔记,旨在介绍javascript在非网页开发领域的应用案例和发现各类好玩的js库,不定期更新.如果你对前端的理解还是写写页面绑绑事件,那你真的是有 ...

  10. rand函数

    srand()用来初始化随机数种子,rand()用来产生随机数 srand(time()); while(t--){ printf("-> %d %d\n",rand(),r ...