黑马程序员SpringBoot2-开发实用篇

视频连接:开发实用篇-67-手工启动热部署_哔哩哔哩_bilibili

热部署

手动启动热部署

黑马程序员SpringBoot2-开发实用篇_第1张图片

热部署仅包含restart的过程。

自动启动热部署

黑马程序员SpringBoot2-开发实用篇_第2张图片

按Ctrl+Alt+Shift+/打开下列界面。

黑马程序员SpringBoot2-开发实用篇_第3张图片

黑马程序员SpringBoot2-开发实用篇_第4张图片

黑马程序员SpringBoot2-开发实用篇_第5张图片

禁用热部署

黑马程序员SpringBoot2-开发实用篇_第6张图片

配置高级

@ConfigurationProperties

黑马程序员SpringBoot2-开发实用篇_第7张图片

黑马程序员SpringBoot2-开发实用篇_第8张图片

黑马程序员SpringBoot2-开发实用篇_第9张图片

宽松绑定/松散绑定

黑马程序员SpringBoot2-开发实用篇_第10张图片

黑马程序员SpringBoot2-开发实用篇_第11张图片

常用计量单位绑定

黑马程序员SpringBoot2-开发实用篇_第12张图片

黑马程序员SpringBoot2-开发实用篇_第13张图片

数据校验

黑马程序员SpringBoot2-开发实用篇_第14张图片黑马程序员SpringBoot2-开发实用篇_第15张图片

设置具体规则。

黑马程序员SpringBoot2-开发实用篇_第16张图片

测试

加载测试专用属性

黑马程序员SpringBoot2-开发实用篇_第17张图片

加载测试专用配置

使得某个配置只能在当前测试类中使用,从而减少配置。

黑马程序员SpringBoot2-开发实用篇_第18张图片

Web环境模拟测试

黑马程序员SpringBoot2-开发实用篇_第19张图片

黑马程序员SpringBoot2-开发实用篇_第20张图片

查看调用过程是否成功。

黑马程序员SpringBoot2-开发实用篇_第21张图片

查看执行结果是否符合预期(感觉有点麻烦,如果返回结果不是字符串呢,我还得自己写一个一模一样的返回结果?)。奥,应该可以只判断返回结果中的某个属性是不是符合预期。

黑马程序员SpringBoot2-开发实用篇_第22张图片

黑马程序员SpringBoot2-开发实用篇_第23张图片

请求头匹配,感觉意义不大。

黑马程序员SpringBoot2-开发实用篇_第24张图片

数据层测试回滚

为测试类加上@Transactional注解,防止运行程序的时候测试类对数据库进行操作。

黑马程序员SpringBoot2-开发实用篇_第25张图片

测试用例数据设定

黑马程序员SpringBoot2-开发实用篇_第26张图片

数据层解决方案

SQL层

这一章主要讲的是SpringBoot自己内置的数据源、持久化技术、内置数据库。

数据源配置

如果没有指定数据源类型,springboot会采取默认数据源对象hikari,具体配置有区别需要自己查。

黑马程序员SpringBoot2-开发实用篇_第27张图片

内置持久化解决方案——jdbcTemplate

比较原始的jdbc技术。比较繁琐。JdbcTemplateSpringJDBC的封装,应用于dao层,对数据库进行CRUD的操作。

黑马程序员SpringBoot2-开发实用篇_第28张图片

黑马程序员SpringBoot2-开发实用篇_第29张图片

黑马程序员SpringBoot2-开发实用篇_第30张图片

内嵌数据库(H2)

导包

黑马程序员SpringBoot2-开发实用篇_第31张图片

初次启动需要声明数据源。

黑马程序员SpringBoot2-开发实用篇_第32张图片

配置完后启动,浏览器url输入localhost/h2进入控制台。

黑马程序员SpringBoot2-开发实用篇_第33张图片

黑马程序员SpringBoot2-开发实用篇_第34张图片

NoSQL

Redis

黑马程序员SpringBoot2-开发实用篇_第35张图片

SpringBoot整合

黑马程序员SpringBoot2-开发实用篇_第36张图片

黑马程序员SpringBoot2-开发实用篇_第37张图片

使用RedisTemplate类操作redis数据库。

黑马程序员SpringBoot2-开发实用篇_第38张图片

黑马程序员SpringBoot2-开发实用篇_第39张图片

直接使用RedisTemplate使用的是对象映射,在客户端中可能查询不到对象,可以修改为使用StringTemplate或者指定泛型为String。

黑马程序员SpringBoot2-开发实用篇_第40张图片

黑马程序员SpringBoot2-开发实用篇_第41张图片

jedis

edis是一个用Java编写的Redis客户端,包含易于使用Redis的API。

黑马程序员SpringBoot2-开发实用篇_第42张图片

springboot默认的客户端是Lettuce,性能较高,但为了与之前的软件兼容,可以改为jedis。

黑马程序员SpringBoot2-开发实用篇_第43张图片

黑马程序员SpringBoot2-开发实用篇_第44张图片

mongo

又能操作结构化数据,又能高响应速度。

应用场景

黑马程序员SpringBoot2-开发实用篇_第45张图片

下载安装

下面的../data/db文件夹需要自己创建。

黑马程序员SpringBoot2-开发实用篇_第46张图片

黑马程序员SpringBoot2-开发实用篇_第47张图片

黑马程序员SpringBoot2-开发实用篇_第48张图片

基本操作

黑马程序员SpringBoot2-开发实用篇_第49张图片

黑马程序员SpringBoot2-开发实用篇_第50张图片

Springboot整合MongoDB

黑马程序员SpringBoot2-开发实用篇_第51张图片

黑马程序员SpringBoot2-开发实用篇_第52张图片

黑马程序员SpringBoot2-开发实用篇_第53张图片

ES(Elasticsearch)

适用于根据关键字查询信息,这里的倒排索引表示根据关键字查询id,创建文档表示创建对应数据(关键字-id-数据)的数据结构,方便快速展示,使用文档表示输入关键字查询到对应信息。

黑马程序员SpringBoot2-开发实用篇_第54张图片

下载与安装

黑马程序员SpringBoot2-开发实用篇_第55张图片

基础操作

这里的索引大概的意思是表示查询的方式,通过制定mappings进行设定。

黑马程序员SpringBoot2-开发实用篇_第56张图片

下载分词器,放在plugin目录下。

黑马程序员SpringBoot2-开发实用篇_第57张图片

黑马程序员SpringBoot2-开发实用篇_第58张图片

文档就是数据。

黑马程序员SpringBoot2-开发实用篇_第59张图片

黑马程序员SpringBoot2-开发实用篇_第60张图片

黑马程序员SpringBoot2-开发实用篇_第61张图片

整合SpringBoot的操作

下面引入json需要导入fastjson。

黑马程序员SpringBoot2-开发实用篇_第62张图片

黑马程序员SpringBoot2-开发实用篇_第63张图片

黑马程序员SpringBoot2-开发实用篇_第64张图片

黑马程序员SpringBoot2-开发实用篇_第65张图片

黑马程序员SpringBoot2-开发实用篇_第66张图片

整合第三方技术

缓存

黑马程序员SpringBoot2-开发实用篇_第67张图片

缓存使用

黑马程序员SpringBoot2-开发实用篇_第68张图片

黑马程序员SpringBoot2-开发实用篇_第69张图片

黑马程序员SpringBoot2-开发实用篇_第70张图片

手机验证码案例

黑马程序员SpringBoot2-开发实用篇_第71张图片

黑马程序员SpringBoot2-开发实用篇_第72张图片

后面没有ppt...

缓存供应商变更:Ehache

黑马程序员SpringBoot2-开发实用篇_第73张图片

xml文件放在resource文件夹下。

黑马程序员SpringBoot2-开发实用篇_第74张图片

黑马程序员SpringBoot2-开发实用篇_第75张图片

黑马程序员SpringBoot2-开发实用篇_第76张图片

数据淘汰的方法

LRU跟时间相关,LFU跟次数相关。

黑马程序员SpringBoot2-开发实用篇_第77张图片

缓存供应商变更:Redis

黑马程序员SpringBoot2-开发实用篇_第78张图片

下面的是进一步配置。

黑马程序员SpringBoot2-开发实用篇_第79张图片

缓存供应商变更:memcached

黑马程序员SpringBoot2-开发实用篇_第80张图片

黑马程序员SpringBoot2-开发实用篇_第81张图片

黑马程序员SpringBoot2-开发实用篇_第82张图片

黑马程序员SpringBoot2-开发实用篇_第83张图片

黑马程序员SpringBoot2-开发实用篇_第84张图片

黑马程序员SpringBoot2-开发实用篇_第85张图片

黑马程序员SpringBoot2-开发实用篇_第86张图片

黑马程序员SpringBoot2-开发实用篇_第87张图片

黑马程序员SpringBoot2-开发实用篇_第88张图片

缓存供应商变更:jetcache

黑马程序员SpringBoot2-开发实用篇_第89张图片

黑马程序员SpringBoot2-开发实用篇_第90张图片

黑马程序员SpringBoot2-开发实用篇_第91张图片

黑马程序员SpringBoot2-开发实用篇_第92张图片

黑马程序员SpringBoot2-开发实用篇_第93张图片

黑马程序员SpringBoot2-开发实用篇_第94张图片

黑马程序员SpringBoot2-开发实用篇_第95张图片

黑马程序员SpringBoot2-开发实用篇_第96张图片

黑马程序员SpringBoot2-开发实用篇_第97张图片

在方法上加缓存。

黑马程序员SpringBoot2-开发实用篇_第98张图片

@CacheRefresh表示过多长时间刷新一下缓存,使得与数据库同步,因为可能有另一个系统更新数据库导致缓存与数据库不一致。

黑马程序员SpringBoot2-开发实用篇_第99张图片

黑马程序员SpringBoot2-开发实用篇_第100张图片

黑马程序员SpringBoot2-开发实用篇_第101张图片

缓存供应商变更:j2cache

j2cache提供了框架,使得不同的缓存技术可以进行整合。其中j2cache-core包中包含了对redis的整合。以下为实现redis和ehcache的整合。

黑马程序员SpringBoot2-开发实用篇_第102张图片

下面redis的provider_class在j2cache-core包中能找到对应的provider类,要使用那个类的全类名。broadcast也是j2cache-core包下的实现类。

黑马程序员SpringBoot2-开发实用篇_第103张图片

黑马程序员SpringBoot2-开发实用篇_第104张图片

黑马程序员SpringBoot2-开发实用篇_第105张图片

任务

整合Quartz

黑马程序员SpringBoot2-开发实用篇_第106张图片

黑马程序员SpringBoot2-开发实用篇_第107张图片

黑马程序员SpringBoot2-开发实用篇_第108张图片

这个不需要指定成bean。

黑马程序员SpringBoot2-开发实用篇_第109张图片

黑马程序员SpringBoot2-开发实用篇_第110张图片

Spring Task

黑马程序员SpringBoot2-开发实用篇_第111张图片

黑马程序员SpringBoot2-开发实用篇_第112张图片

黑马程序员SpringBoot2-开发实用篇_第113张图片

邮件

整合JavaMail

黑马程序员SpringBoot2-开发实用篇_第114张图片

下面的password要填授权码。

黑马程序员SpringBoot2-开发实用篇_第115张图片

黑马程序员SpringBoot2-开发实用篇_第116张图片

黑马程序员SpringBoot2-开发实用篇_第117张图片

黑马程序员SpringBoot2-开发实用篇_第118张图片

消息

将任务分发给子业务系统,分散压力。

黑马程序员SpringBoot2-开发实用篇_第119张图片

三种规范

JMS

黑马程序员SpringBoot2-开发实用篇_第120张图片

AMQP

统一了数据格式,解决了跨平台的问题。

黑马程序员SpringBoot2-开发实用篇_第121张图片

Kafka

ActiveMq

黑马程序员SpringBoot2-开发实用篇_第122张图片

默认目的地。

黑马程序员SpringBoot2-开发实用篇_第123张图片

自定义目的地。

黑马程序员SpringBoot2-开发实用篇_第124张图片

监听器可以直接执行队列中的数据。

黑马程序员SpringBoot2-开发实用篇_第125张图片

黑马程序员SpringBoot2-开发实用篇_第126张图片

RabbitMq

黑马程序员SpringBoot2-开发实用篇_第127张图片

黑马程序员SpringBoot2-开发实用篇_第128张图片

黑马程序员SpringBoot2-开发实用篇_第129张图片

黑马程序员SpringBoot2-开发实用篇_第130张图片

黑马程序员SpringBoot2-开发实用篇_第131张图片

黑马程序员SpringBoot2-开发实用篇_第132张图片

定义了交换机,交换机将队列和键值绑定,收发消息时不直接与队列交换信息,而是根据键值和交换机找相应队列。

黑马程序员SpringBoot2-开发实用篇_第133张图片

黑马程序员SpringBoot2-开发实用篇_第134张图片

监听器监听的注解需要写队列名称。

黑马程序员SpringBoot2-开发实用篇_第135张图片

仅修改了红色部分,字符串匹配的灵活性为多种多样的消息匹配提供了便捷。

黑马程序员SpringBoot2-开发实用篇_第136张图片

黑马程序员SpringBoot2-开发实用篇_第137张图片

黑马程序员SpringBoot2-开发实用篇_第138张图片

黑马程序员SpringBoot2-开发实用篇_第139张图片

RocketMq

黑马程序员SpringBoot2-开发实用篇_第140张图片

为了方便服务器扩容,添加了nameServer。

黑马程序员SpringBoot2-开发实用篇_第141张图片

要想运行成功,需要把jdk版本换到9以下,还要把path中jdk的环境变量中的路径改成没有空格的。

黑马程序员SpringBoot2-开发实用篇_第142张图片

黑马程序员SpringBoot2-开发实用篇_第143张图片

黑马程序员SpringBoot2-开发实用篇_第144张图片

黑马程序员SpringBoot2-开发实用篇_第145张图片

黑马程序员SpringBoot2-开发实用篇_第146张图片

黑马程序员SpringBoot2-开发实用篇_第147张图片

黑马程序员SpringBoot2-开发实用篇_第148张图片

黑马程序员SpringBoot2-开发实用篇_第149张图片

Kafka

黑马程序员SpringBoot2-开发实用篇_第150张图片

黑马程序员SpringBoot2-开发实用篇_第151张图片

黑马程序员SpringBoot2-开发实用篇_第152张图片

黑马程序员SpringBoot2-开发实用篇_第153张图片

黑马程序员SpringBoot2-开发实用篇_第154张图片

黑马程序员SpringBoot2-开发实用篇_第155张图片

黑马程序员SpringBoot2-开发实用篇_第156张图片

监控

监控的意义

左边监控平台主动拉取右边监控信息,右边监控设置是否可以被监控以及展示信息的种类。

黑马程序员SpringBoot2-开发实用篇_第157张图片

可视化监控平台

黑马程序员SpringBoot2-开发实用篇_第158张图片

黑马程序员SpringBoot2-开发实用篇_第159张图片

黑马程序员SpringBoot2-开发实用篇_第160张图片

黑马程序员SpringBoot2-开发实用篇_第161张图片

黑马程序员SpringBoot2-开发实用篇_第162张图片

监控原理

端点名称

黑马程序员SpringBoot2-开发实用篇_第163张图片

黑马程序员SpringBoot2-开发实用篇_第164张图片

黑马程序员SpringBoot2-开发实用篇_第165张图片

暴露出来的端点可以使用web访问也可以使用jmx jconsole方式访问。

黑马程序员SpringBoot2-开发实用篇_第166张图片

黑马程序员SpringBoot2-开发实用篇_第167张图片

自定义监控指标

监控平台的info没有信息,使用如下办法自定义信息。

黑马程序员SpringBoot2-开发实用篇_第168张图片

黑马程序员SpringBoot2-开发实用篇_第169张图片

黑马程序员SpringBoot2-开发实用篇_第170张图片

黑马程序员SpringBoot2-开发实用篇_第171张图片

红线部分要加enabledefault。

黑马程序员SpringBoot2-开发实用篇_第172张图片

你可能感兴趣的:(jenkins,运维)