随笔分类 -  SpringBoot

摘要:1.SpringBoot配置文件 SpringBoot使用一个以application命名的配置文件作为默认的全局配置文件。支持properties后缀结尾的配置文件或者以yml/yaml后缀结尾的YAML的文件配置。 以设置应用端口为例 properties文件示例(application.pro 阅读全文
posted @ 2022-02-09 10:39 牧之丨 阅读(3833) 评论(0) 推荐(1)
摘要:使用 Spring Boot 开发,对外开发接口供调用,传入参数中有中文,出现中文乱码,查了好多资料,总结解决方法如下: 第一步,约定传参编码格式 不管是使用httpclient,还是okhttp,都要设置传参的编码,为了统一,这里全部设置为utf-8 第二步,修改application.prope 阅读全文
posted @ 2021-11-09 15:11 牧之丨 阅读(6484) 评论(0) 推荐(0)
摘要:查看当前使用的Tomcat版本号# Maven Repository中查看# 比如我们需要查Spring Boot 2.1.4-RELEASE的内嵌Tomcat版本, 可以打开链接: Copy https://mvnrepository.com/artifact/org.springframewor 阅读全文
posted @ 2021-10-29 10:51 牧之丨 阅读(8629) 评论(0) 推荐(0)
摘要:登录实现拿浏览器网页登录举例: 基于 OAuth2.0-密码模式 实现网页登录的本质就是浏览器通过 /oauth/token 接口将 用户名 和 密码 等信息传给后台, 然后后台验证通过后返回一个有效的 token 给浏览器. 通过 curl 命令发送请求 请求头 Authorization 存放的 阅读全文
posted @ 2021-10-12 22:24 牧之丨 阅读(732) 评论(0) 推荐(0)
摘要:使用springboot开发一个RESTful API服务,配置了@ControllerAdvice,其它类型异常都能正常捕获,就是不能捕获NoHandlerFoundException, 安装以往使用springmvc的经验,需要设置DispatcherServlet.throwException 阅读全文
posted @ 2021-01-15 18:20 牧之丨 阅读(1156) 评论(0) 推荐(0)
摘要:yml:myProps: varmaplist: key11: - t1 - t2 - t3 key22: - t11 - t22 - t33 list: - topic1 - topic2 - topic3 maps: {key1: 'value1', key2: 'value2'} MyProp 阅读全文
posted @ 2020-12-18 14:37 牧之丨 阅读(1219) 评论(0) 推荐(0)
摘要:目录 一、背景介绍 1、什么是RestTemplate? 2、RestTemplate的优缺点: 二、配置RestTemplate 1、引入依赖 2、连接池配置 3、初始化连接池 4、使用示例 三、RestTemplate常用方法 1、getForEntity 2、getForObject 3、po 阅读全文
posted @ 2020-10-10 23:22 牧之丨 阅读(1312) 评论(0) 推荐(0)
摘要:编辑推荐: 本文来源简书,介绍了一种只需在服务端进行授权即可,无需在前端添加额外设置,比传统的JSONP跨域更安全和便捷的方式CORS。 一、基本介绍 简单来说,CORS是一种访问机制,英文全称是Cross-Origin Resource Sharing,即我们常说的跨域资源共享,通过在服务器端设置 阅读全文
posted @ 2020-08-31 14:59 牧之丨 阅读(469) 评论(0) 推荐(0)
摘要:http://www.imooc.com/article/290828 Spring Cloud Gatway内置的 RequestRateLimiterGatewayFilterFactory 提供限流的能力,基于令牌桶算法实现。目前,它内置的 RedisRateLimiter ,依赖Redis存 阅读全文
posted @ 2020-08-26 10:46 牧之丨 阅读(897) 评论(0) 推荐(0)
摘要:http://www.imooc.com/article/290804 TIPS 本文基于Spring Cloud Greenwich SR2编写,兼容Spring Cloud Finchley及更高版本。 这一节来详细探讨Spring Cloud Gateway的路由谓词工厂 (Route Pre 阅读全文
posted @ 2020-08-26 10:44 牧之丨 阅读(569) 评论(0) 推荐(0)
摘要:http://www.imooc.com/article/290824 本文总结Spring Cloud Gateway的排错、调试技巧。欢迎留言补充! 第一式:Actuator监控端点 借助Actuator的监控端点,可分析全局过滤器、过滤器工厂、路由详情。详见:Spring Cloud Gate 阅读全文
posted @ 2020-08-26 10:39 牧之丨 阅读(1043) 评论(0) 推荐(0)
摘要:http://www.imooc.com/article/290822 欢迎加入Spring Cloud Gateway监控豪华套餐—— 只要为Spring Cloud Gateway添加Spring Boot Actuator( spring-boot-starter-actuator )的依赖, 阅读全文
posted @ 2020-08-26 10:33 牧之丨 阅读(1333) 评论(0) 推荐(0)
摘要:http://www.imooc.com/article/290821 TIPS 本文基于Spring Cloud Gateway SR2,理论适配Spring Cloud Gateway SR1以及更高版本。 本文详细探讨Spring Cloud Gateway内置的全局过滤器。包括:1 Comb 阅读全文
posted @ 2020-08-26 10:25 牧之丨 阅读(515) 评论(0) 推荐(0)
摘要:http://www.imooc.com/article/290816 TIPS 本文基于 Spring Cloud Greenwich SR2 ,理论支持 Spring Cloud Greenwich SR1 ,其中的新特性标注出来了。 这一节来探讨Spring Cloud Gateway内置的F 阅读全文
posted @ 2020-08-26 10:24 牧之丨 阅读(660) 评论(0) 推荐(0)
摘要:把这两个勾选去掉 阅读全文
posted @ 2020-08-03 13:44 牧之丨 阅读(2984) 评论(0) 推荐(0)
摘要:背景 在系统生命周期中, 免不了要做升级部署, 对于关键服务, 我们应该能做到不停服务完成升级 (perform a zero downtime upgrade), 对于一般系统, 应该做到优雅地停服务. 如何做到不停服务的升级? 需要做到下面两点:1. 服务本身应该部署多份, 前面应该有 LVS/ 阅读全文
posted @ 2020-06-12 13:22 牧之丨 阅读(1814) 评论(0) 推荐(1)
只有注册用户登录后才能阅读该文。
posted @ 2019-09-25 00:10 牧之丨 阅读(4) 评论(0) 推荐(0)
摘要:设计初衷是通过websocket实现网页实时通讯聊天。 工程环境:tomcat8+jdk1.7+maven+eclipse 设计思路:客户端登录网页建立socket连接,后台记录用户连接信息并做标识;当用户在网页端发送聊天消息至后台,后台收到信息后将消息发送至接收者,同时后端对消息进行持久保存。 简 阅读全文
posted @ 2019-09-25 00:05 牧之丨 阅读(2031) 评论(0) 推荐(0)
摘要:@Component @ServerEndpoint(value = "/endpoint/ws") public class WebSocketServer { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final AtomicInteger onlineCount = ne 阅读全文
posted @ 2019-09-24 22:50 牧之丨 阅读(4403) 评论(0) 推荐(0)
摘要:1.SockJS用javascript实现的socket连接,兼容各种浏览器的WebSocket支持库2.WebSocket是H5的,不支持H5的浏览器没法使用。3.SockJS它提供类似于websocket的编程模式但是可以适应不同的浏览器(包括不支持websocket的浏览器)。后端代码: Ja 阅读全文
posted @ 2019-09-24 22:38 牧之丨 阅读(2278) 评论(1) 推荐(1)