![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SpringCloud
有志青年_ZM
研发路上的菜鸟
展开
-
如何干掉Try{}Catch{}
软件开发过程中,不可避免的是需要处理各种异,所以代码中就会出现大量的try {...} catch {...} finally {...}代码块,不仅有大量的冗余代码,而且还影响代码的可读性。Controller层抛出大量异常,那是相当的难看,所以尽量是在Service层处理业务时进行统一处理。不管是在哪层处理,异常肯定是需要处理,既然不能显示的处理,那只能尽量优雅着来喽。那么怎么处理才算是优雅呢?用Assert(断言)替换throw Exception使用Assert(断言)方式来校...原创 2020-07-02 18:57:24 · 1139 阅读 · 1 评论 -
SpringBoot 整合WebSocket
写在前面的话:一直了解,但是并没有整合过代码,刚好项目用到,仅做记录。上!代!码!1.server端第一步:首先继承 WebSocketConfigurer 创建 配置import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotat...原创 2019-05-17 12:55:25 · 132 阅读 · 0 评论 -
Spring Cloud Bus 动态刷新配置
一、前置条件:1.Spring Boot 2.X2.安装rabbitmq二、configServer 改造:1.新增依赖<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bus-am...原创 2018-12-01 17:16:29 · 195 阅读 · 0 评论