非常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. iPhone多次输入错误密码锁机后刷机恢复(原有内容会丢失)

    这个操作会完全丢失手机当前存储的资料,已经备份到iTunes的内容,将来可以通过iTunes恢复.已经被自动备份到iCloud的内容,比如通讯录,将来可以自动从iCloud恢复.以前没有备份过的资料, ...

  2. c#进程、定时器初步学习

    首先是什么原因让我做这个小项目的呢,是因为在知乎里看到的游侠的文章才尝试着自己做的,文章地址是:https://www.zhihu.com/question/48811975 开始做的时候我是照着文章 ...

  3. Java面试系列--java基础

    Java基础总结 JAVA中的几种基本数据类型是什么,各自占用多少字节. 八大基本数据类型,byte:8位,short:16位,int:32位,long:64位,float:32位,double:64 ...

  4. 【野草】SQL Server之索引解析(二)

    1.堆表 堆表通过IAM连接一起,查询时全表扫描. 1.1 非聚集索引 结构 叶子节点数据结构:行数据结构+Rid(8字节) 中间节点数据结构: (非聚集非唯一索引)行数据结构+Page(4)+2+ ...

  5. 【转】MVC HtmlHelper用法大全

    HtmlHelper用来在视图中呈现 HTML 控件. 以下列表显示了当前可用的一些 HTML 帮助器. 本主题演示所列出的带有星号 (*) 的帮助器. ActionLink - 链接到操作方法. B ...

  6. 接口测试之深入理解HTTPS

    前言 随着网络安全问题越来越被重视,HTTPS协议的使用已经逐渐主流化.目前的主流站点均已使用了HTTPS协议:比如:百度.淘宝.京东等一二线主站都已经迁移到HTTPS服务之上.而作为测试人员来讲,也 ...

  7. [leetcode](4.21)2. 按字典序排列最小的等效字符串

    给出长度相同的两个字符串:A 和 B,其中 A[i] 和 B[i] 是一组等价字符.举个例子,如果 A = "abc" 且 B = "cde",那么就有 'a' ...

  8. excel使用poi操作。

    String real_path = request.getSession().getServletContext().getRealPath("/");//获取文件路径,我是通过 ...

  9. 6-Redis 的持久化之 AOF

    2017-01-01 16:42:13 该系列文章链接NoSQL 数据库简介Redis的安装及及一些杂项基础知识Redis 的常用五大数据类型(key,string,hash,list,set,zse ...

  10. CSS3 font-face使用

    在 CSS3 之前,web 设计师必须使用已在用户计算机上安装好的字体. 通过 CSS3,web 设计师可以使用他们喜欢的任意字体. 当您找到或购买到希望使用的字体时,可将该字体文件存放到 web 服 ...