1、seata 1.1、seata简介 seata官网:http://seata.io/zh-cn/docs/overview/what-is-seata.html 1.2、seata下载安装 seata下载地址 http://seata.io/zh-cn/blog/download.html 我下载的版本是1.3.0版本,下载完直接解压即可 1.3、服务端配置 进入conf文件里面有两个关键的配置文件,第一个是file.conf,第二个是registry.conf 1.3.1、file.conf file.conf配置了seata运行时数据的存储位置,可选项有file,db,redis,将mode改为自己要配置的模式,然后更改下面对应的配置即可,我使用了db,就更改db对应的配置 ## transaction log store, only used in seata-server store { ## store mode: file、db、redis mode = "db" ## file store property file { ## store location dir d.... 有更新! seata配合nacos使用 程序人生
1、简介 spring boot项目启动时可以配置一些参数,我们可以通过实现ApplicationRunner或CommandLineRunner接口,并重写run方法来获取这些配置,如果项目内定义了多个类实现了这两个类的话,通过@Order注解来指定他们的执行顺序。 spring boot项目可以在启动的时候指定项目运行参数,eg: java -jar --user=wenyl 2、ApplicationRunner 2.1、源码解析 ApplicationRunner的run方法参数是ApplicationArguments,内部共有五个方法 public interface ApplicationArguments { String[] getSourceArgs(); Set<String> getOptionNames(); boolean containsOption(String name); List<String> getOptionValues(String name); List<String> getNonOptionArgs.... 有更新! spring boot读取项目参数配置 程序人生
1、简介 spring cloud的负载均衡由ribbon组件实现,ribbon是NetFlix发布的客户端负载均衡器。 2、ribbon负载均衡规则 ribbon负载均衡策略的结构类图 IRule接口中共有三个方法 抽象类AbstractLoadBalancerRule实现了IRule接口,定义了一个ILoadBalancer类型变量,用于ILoadBalancer接口定义了软负载均衡的操作方法。 3、负载均衡策略 3.1、轮询策略 轮询策略在RoundRobinRule类中实现,它将可用服务存储在一个List中,然后定义了一个原子操作类,每次调用就+1,下次调用就把这个值作为List的下标,以此决定要调用哪个服务。 下面是定义,在RoundRobinRule构造函数中,会初始化值为0 3.2、随机策略 随机策略在RandomRule实现,RandomRule定义规则,从现有服务中,随机选择一个服务,具体做法就是根据可选服务数量,选出一个随机数作为下标,获取服务 3.3、根据响应时间分配权重的策略 这个策略由WeightedResponseTimeRule实现,使用这个策略的话,相应.... 有更新! ribbon的几种负载均衡 程序人生
nacos安装准备工作参考spring cloud整合nacos 1、pom引入依赖 主要是spring-cloud-starter-gateway <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.com.wenyl.alibaba</groupId> <artifactId>gateway</artifactId> <version>1.0-SNAPSH.... 有更新! spring cloud gateway配置 程序人生
spring security通过定义多个AuthenticationProvider来实现不同的认证方式。 1、自定义认证器 自定义认证器可以通过实现AuthenticationProvider接口来实现,这个接口,一共有两个方法 public interface AuthenticationProvider { /** * Performs authentication with the same contract as * {@link org.springframework.security.authentication.AuthenticationManager#authenticate(Authentication)} * . * @param authentication the authentication request object. * @return a fully authenticated object including credentials. May return * <code>null</code> if the <c.... spring security支持多个认证方法 程序人生