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 ...
随机推荐
- Java 8的用法(泛型接口,谓词链)
1.泛型接口 我们举个例子,以前来看一下JPA定义的写法: Specification接口为: public interface Specification<T> { Predicate ...
- 设计模式总结篇系列:外观模式(Facade)
张三自从毕业后开始做软件开发,做着做着发现不爽了,钱赚不了太多,头发也白了.于是拿着一点小资本,想着做点小生意.瞅着眼前的餐饮行业还不错,于是打算开一家餐馆.开参观可不是一件容易的事,仅仅行政类的审批 ...
- Linux 的进程间通信:管道
本文由云+社区发表 作者:邹立巍 版权声明: 本文章内容在非商业使用前提下可无需授权任意转载.发布. 转载.发布请务必注明作者和其微博.微信公众号地址,以便读者询问问题和甄误反馈,共同进步. 微博ID ...
- PWA的探索与应用
本文由云+社区发表 PWA(Progressive Web App)起源背景 传统的Web网页存在以下几个问题: 进入一个页面必须要记住它的url或者加入书签,入口不便捷: 没网络就没响应,不具备离线 ...
- Ruby Enumerator的各种迭代
Enumerator迭代 Mix-in Enumerator获得的迭代方法: each_cons: each_slice: each_with_index: with_index: each_with ...
- SmoOne——开源免费的企业移动OA应用,基于.Net
一.SmoOne是什么一个开源的移动OA应用 二.语言C# 三.开发环境Visual Studio 四.开发平台Smobiler Designer 五.功能该应用开源代码中包含注册.登录.用户信息等基 ...
- Java开发笔记(七十五)异常的处理:扔出与捕捉
前面介绍的几种异常(不包含错误),编码的时候没认真看还发现不了,直到程序运行到特定的代码跑不下去了,程序员才会恍然大悟:原来这里的代码逻辑有问题.像这些在运行的时候才暴露出来的异常,又被称作“运行时异 ...
- myeclipse的debug模式启动不了,但run模式可以启动
一.问题 在用myeclipse的开发web项目时,经常会打断点,然后利用debug模式启动.但是,今天debug模式启动不了,run模式又可以.这给调试带来了很大的麻烦. 二.解决办法 1.点击de ...
- BaseServlet的编写
在BaseServlet之前,需要提及工厂factory去管理dao以及service,以及页面转发或重定向的管理 1.创建一个工厂类,以及一个资源文件,资源文件中以键值对的形式去存储key,以及对应 ...
- 原生JS实现简易轮播图
原生JS实现简易轮播图(渐变?) 最近做网页总是会用到轮播图,我就把之前写的轮播图单独拿出来吧,如果有...如果真的有人也需要也可以复制去用用啊..哈~.. window.onload = funct ...