spring boot 的一些高级用法
1 spring boot 项目的创建
参考 https://www.cnblogs.com/PerZhu/p/10708809.html
2 首先我们先把Maven里面的配置完成

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency> <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
3 属性配置建议使用application.yml,里面用来配置数据库的连接,还有数据库里面表的创建方式,和端口号的选择


Controller处理http注解
Controller需要和模板一起使用(简单了解即可),首先需要在maven里面加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>




4 URL 注解的使用



5 数据库的操作

首先添加注解
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
创建一个Girl类来对应数据库里面的表

package com.zzy; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id; @Entity public class Girl {
@Id
@GeneratedValue
private Integer id; private Integer age; private String height; public Girl() {
} public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getHeight() {
return height;
} public void setHeight(String height) {
this.height = height;
} public Integer getAge() {
return age;
} public void setAge(Integer age) {
this.age = age;
} @Override
public String toString() {
return "Girl{" +
"id=" + id +
", age=" + age +
", height='" + height + '\'' +
'}';
}
}

创建刚开始的几个接口

创建一个接口



添加一个女生



查询一个女生


更新一条记录



删除一条记录



数据库的增,更,删,填,都具备了
通过年龄来查询




spring boot 的一些高级用法的更多相关文章
- Spring Boot 缓存的基本用法
目录 一.目的 二.JSR-107 缓存规范 三.Spring 缓存抽象 四.Demo 1.使用 IDEA 创建 Spring Boot 项目 2.创建相应的数据表 3.创建 Java Bean 封装 ...
- spring boot中@ControllerAdvice的用法
@ControllerAdvice ,这是一个增强的 Controller.使用这个 Controller ,可以实现三个方面的功能: 全局异常处理 全局数据绑定 全局数据预处理 灵活使用这三个功能, ...
- spring boot actuator端点高级进阶metris指标详解、git配置详解、自定义扩展详解
https://www.cnblogs.com/duanxz/p/3508267.html 前言 接着上一篇<Springboot Actuator之一:执行器Actuator入门介绍>a ...
- spring boot redis 数据库缓存用法
缓存处理方式应该是 1.先从缓存中拿数据,如果有,直接返回.2.如果拿到的为空,则数据库查询,然后将查询结果存到缓存中.由此实现方式应该如下: private String baseKey = &qu ...
- jsp标签在spring boot中的关键用法
<form:form modelAttribute="user" action="save" method="post" >// ...
- springboot(十九):使用Spring Boot Actuator监控应用
微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...
- (转)Spring Boot (十九):使用 Spring Boot Actuator 监控应用
http://www.ityouknow.com/springboot/2018/02/06/spring-boot-actuator.html 微服务的特点决定了功能模块的部署是分布式的,大部分功能 ...
- Spring Boot Actuator监控应用
微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...
- spring Boot(十九):使用Spring Boot Actuator监控应用
spring Boot(十九):使用Spring Boot Actuator监控应用 微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台 ...
随机推荐
- delete和析构函数
new一个类的时候,调用这个类的构造函数,然后在这个类的生命周期内可能会动态生成很多指向堆上的内存,所以应该在析构函数里回收这些内存: 当delete这个类的时候,会首先调用这个类的析构函数,即回收生 ...
- uni-app 使用 iconfont 图标 自定义图标
uni-app 的uni-ui 的 Icon 图标组件,裡面的图标只是移动端常见的图标,对于一些其他需求所要显示的图标,这个是完全不够用.那么怎么办?模仿它的组件,用阿里巴巴图标矢量库的图标,自己定义 ...
- 查看mycat日志
查看日志: tail -f /usr/local/mycat/logs/wrapper.log
- 使用xhprof进行线上PHP性能追踪及分析
转自: http://avnpc.com/pages/profiler-php-performance-online-by-xhprof
- antd二级联动异步加载
/** * Created by Admin on 2016/9/19. * 批量导入 */ import React, {Component, PropTypes} from "react ...
- Vue input 控件: 通过自定义指令(directive)使用正则表达式限制input控件的输入
前言: 网站中的input输入框使用非常广泛,因业务场景不同需要对输入框做合法性校验或限制输入,比如电话号码.邮件.区号.身份证号等.input框的不合法内容主要有两种方式处理:1.用户输入内容后,通 ...
- eNSP——通过Stelnet登录系统
Stelnet的原理 由于Telnet缺少安全的认证方式,而且传输过程采用TCP进行明文传输,存在很大的安全隐患,单纯提供Telnet服务容易招致主机IP地址欺骗.路由欺骗等恶意攻击.传统的Telne ...
- Reactor系列(五)map映射
#java# #reactor# #flux# #map# #映射# 视频解视: https://www.bilibili.com/video/av79179444/ FluxMonoTestCase ...
- Reactor系列(二)Flux Mono创建
Flux Mono创建 视频讲解:https://www.bilibili.com/video/av78844777/ FluxMonoTestCase.java package com.exampl ...
- *#【Python】【基础知识】【模块】【random】【使用random创造一个随机数】
Random介绍: 输出随机数. 快照: #!/usr/bin/python # -*- coding: UTF-8 -*- import random #生成 10 到 20 之间的随机数 prin ...