04 2020 档案
摘要:@Component @Configuration public class GateWayFilter implements GlobalFilter, Ordered { @Override public Mono<Void> filter(ServerWebExchange exchange,
阅读全文
摘要:io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /192.168.8.13:8002 Suppressed: reactor.core.pu
阅读全文
摘要:构建于springboot2.x,spring webFlux,project reactor之上,更加符合未来的技术体系 使用非阻塞的方式 pom <!--gateway--> <dependency> <groupId>org.springframework.cloud</groupId> <a
阅读全文
摘要:1:方法的熔断 /** * 服务熔断 * * @return */ @HystrixCommand(fallbackMethod = "numLessZeroException", commandProperties = { //ctrl+shift+A 查询HystrixCommandProper
阅读全文
摘要:1:pom <!-- hystrix --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </depen
阅读全文
摘要:pom <!-- hystrix--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependen
阅读全文
摘要:yml配置 #自定义ribbon的超时时间 ribbon: ReadTimeout: 5000 #处理请求的超时时间,默认为5秒 ConnectTimeout: 5000 #连接建立的超时时长,默认5秒 MaxAutoRetries: 1 #同一台实例的最大重试次数,但是不包括首次调用,默认为1次
阅读全文
摘要:ribbon的使用方式 ribbon调用服务方式 ribbon+restTemplete openFeign的调用服务方式 controller层直接调用service openFeign是对ribbon做了进一步的封装
阅读全文
摘要:作用 类似ribbon提供客户端的负载均衡 1:pom <! eureka-client --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eu
阅读全文
摘要:作用 客户端的负载均衡,与RestTemplate结合使用 1:pom eureka的客户端与nocos的客户端pom依赖,都集成了ribbon,所以不再需要重复添加依赖 2:将RestTemplate注入到spring容i中 @Component @Configuration public cla
阅读全文
摘要:cap模型 CAP原则又称CAP定理,指的是在一个分布式系统中,一致性(Consistency)、可用性(Availability)、分区容错性(Partition tolerance)。CAP 原则指的是,这三个要素最多只能同时实现两点,不可能三者兼顾 一致性(Consistency):同一时间看
阅读全文
摘要:1:pom <!-- nacos-discovery --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
阅读全文
摘要:1:作用 本地调试的时候,不用跑相同的项目,就可以模拟多个相同服务的实例 2:步骤 2.1 右键payment copy configuaration 2.2 修改名字 与 VM options -DServer.port=9011 9001端口映射到9011 2.3 nacos查看 2.4 访问测
阅读全文
摘要:1:pom 1.1:父pom <!--Spring cloud alibaba dependencies --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependenci
阅读全文
摘要:1:下载 https://github.com/alibaba/nacos/releases 网盘下载地址 1.2.1版本 链接:https://pan.baidu.com/s/1DM-ZlLvpmtK0OOcAl-Rj4g 提取码:rt5v 2:安装运行 运行bin下面的命令 3:查看运行结果 h
阅读全文
摘要:1:注入 DiscoveryClient // import org.springframework.cloud.client.discovery.DiscoveryClient; @Autowired private DiscoveryClient discoveryClient; 2:对外提供方
阅读全文
摘要:yml eureka: client: fetch-registry: true register-with-eureka: true service-url: defaultZone: http://eureka7002.com:7002/eureka/,http://eureka7001.com
阅读全文
摘要:yml spring: application: name: cloud-payment-service # 也是注册到eureka服务的名称( 服务别名(使用服务别名去注册中心获取实际的RPC远程调用地址) ) 名字相同,则为注册的相同的服务,不同的实例(该名称不可随意改动,否则,client调用
阅读全文
摘要:yml 消费端 eureka: client: fetch-registry: true register-with-eureka: true service-url: defaultZone: http://eureka7002.com:7002/eureka/,http://eureka7001
阅读全文
摘要:分配端口 7001 7002 7003 yml eureka: instance: hostname: eureka7001.com #eureka服务端的实例名称 client: register-with-eureka: false #false表示不向注册中心注册自己 fetch-regist
阅读全文
摘要:1:pom <! eureka-client --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactI
阅读全文
摘要:1:pom依赖 <! eureka-client --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifac
阅读全文
摘要:1:pom依赖 <! eureka-server --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifac
阅读全文
摘要:1:添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</o
阅读全文
摘要:推荐版本 spring cloud Hocton.SR1 spring boot 2.2.2RELEASE cloud alibaba 2.1.0RELEASE java java8 maven 3.5以上 mysql 5.7以上 停更与替换 服务注册中心 eureka -> zookeeper /
阅读全文
摘要:需求:查询订单要返回用户名 为了解耦,查询订单中不查询用户,使用aop自动注入用户名 注意:订单列表中的用户缓存到了内存,遍历查询很快,如果直接查数据库,则效率相对低 思路:对返回值加强(aop对返回值增强,向订单表中注入userName) 1.注解 /** * 设置属性非空的开关 * 只有方法上加
阅读全文
摘要:重要方法 /*获取参数的值数组*/ Object[] args = point.getArgs(); // [1] 参数的值 /*获取目标对象(被加强的对象)*/ Object target = point.getTarget(); /*获取signature 该注解作用在方法上,强转为 Metho
阅读全文
摘要:作用:增强方法 本例基于 反射+注解+aspect 流程 1:创建注解(标识哪个方法使用aop,也可以直接使用表达式) 2:创建切面 3:创建方法,使用注解标记 1:创建注解 /** * 标记**方法使用 WebAspect 切面 */ @Retention(RetentionPolicy.RUNT
阅读全文
摘要:@Component public class SpringContext implements ApplicationContextAware { // Spring应用上下文环境 private static ApplicationContext applicationContext; /**
阅读全文
摘要:作用: spring所有Bean生成之后,加载一些数据和执行一些应用的初始化 使用 @Order(value = 1) // 多个实现时定义执行顺序 @Component public class ApplicationInit implements CommandLineRunner, Appli
阅读全文
摘要:SET GLOBAL log_bin_trust_function_creators = 1; DELIMITER $$ CREATE FUNCTION pro_salary_grade( salary INT) RETURNS CHAR BEGIN DECLARE grade CHAR DEFAU
阅读全文
摘要:DELIMITER $$ CREATE PROCEDURE pro_insert(IN maxNum INT) BEGIN DECLARE i INT DEFAULT(1); while i<=maxNum DO INSERT INTO employees (first_name ,last_nam
阅读全文
摘要:# 无参存储过程 DELIMITER $$ CREATE PROCEDURE pro_insert_employees() BEGIN insert into employees (first_name,last_name) VALUES("1","1"),("2","2"),("3","3");
阅读全文
摘要:#select的标量子查询 # 查询每个用户的订单数量 SELECT u.id,u.user_name,u.phone,(SELECT COUNT(1) FROM user_order uo WHERE uo.owner_id=u.id ) as num FROM sys_user u; #查询下过
阅读全文
摘要:SELECT CHAR_LENGTH("qwer种"); SELECT LENGTH("qwer种"); SELECT CONCAT("s1"," ","s2"); #每个字符串之间要加上 x,x 可以是分隔符 SELECT CONCAT_WS( " ", "我", "是", "谁" ); # 返回
阅读全文

浙公网安备 33010602011771号