spring-cloud

springcloud 配置中心(git+config+consul+databus)

99封情书 提交于 2020-03-15 23:49:01
本文主要实现,基于 Spring Cloud Config和git databus实现配置中心以及配置的动态刷新,以及用户认证,加密,解密的功能(代码地址 点这里 ),本文没有原理性的讲解,就是直接讲述怎么使用,原理请自行阅读官方文档 Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持, 它分为服务端与客户端两个部分。其中服务端也称为分布式配置中心,它是一个独立的微服务应用,用来连接配置仓库并为客户端提供获取配置信息、加密 / 解密信息等访问接口; 而客户端则是微服务架构中的各个微服务应用或基础设施,它们通过指定的配置中心来管理应用资源与业务相关的配置内容,并在启动的时候从配置中心获取和加载配置信息。 Spring Cloud Config 实现了对服务端和客户端中环境变量和属性配置的抽象映射,所以它除了适用于 Spring 构建的应用程序之外,也可以在任何其他语言运行的应用程序中使用。由于 Spring Cloud Config 实现的配置中心默认采用 Git 来存储配置信息,所以使用 Spring Cloud Config 构建的配置服务器,天然就支持对微服务应用配置信息的版本管理,并且可以通过 Git 客户端工具来方便的管理和访问配置内容

SpringCloud使用

喜夏-厌秋 提交于 2020-03-11 08:24:31
一、微服务发现组件Eureka的使用 1.父工程中管理springcloud版本 <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Finchley.M9</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> 2.搭建Eureka注册中心 1)创建Eureka注册中心模块tenpower-eureka,添加依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> 2)该模块application.yml配置 server: port: 6868 eureka: client: register-with-eureka: false

[CVE-2020-5405]Directory Traversal with spring-cloud-config-server

南楼画角 提交于 2020-03-08 12:54:21
环境: https://github.com/shadowsock5/spring-cloud-config-starter 启动完成: curl -u root:root http://192.168.170.139:8888/cqq-config/test 修复的commit是这个: https://github.com/spring-cloud/spring-cloud-config/commit/651f458919c40ef9a5e93e7d76bf98575910fad0 参考: CVE-2020-5405: Directory Traversal with spring-cloud-config-server 【漏洞通告】Spring-cloud-config-server路径遍历漏洞(CVE-2020-5405)通告 https://www.baeldung.com/spring-cloud-configuration https://howtodoinjava.com/spring-cloud/spring-cloud-config-server-git/ http://www.ityouknow.com/springcloud/2017/05/22/springcloud-config-git.html https://github.com/ityouknow

聊聊skywalking的spring-cloud-gateway-plugin

假如想象 提交于 2020-03-07 10:33:09
序 本文主要研究一下skywalking的spring-cloud-gateway-plugin NettyRoutingFilterInstrumentation skywalking-6.6.0/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java public class NettyRoutingFilterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; } @Override public InstanceMethodsInterceptPoint[]

org.springframework.cloud:spring-cloud-starter-eureka :unknown 报错解决;

让人想犯罪 __ 提交于 2020-03-05 19:52:19
Spring Cloud Eureka是对Netflix Eureka的二次封装。 Eureka服务端 Eureka就是注册中心,同时它也是一个客户端——Eureka server(Eureka服务端)同是也是Eureka Client(Eureka客户端)。 Eureka客户端 提供服务,向注册中心注册自服务,定时发送心跳给注册中心以更新当前服务的可用状态。也可以从注册中心查询注册的服务信息。 由于版本都是需要父类来管理的,所有在父类的pom文件里面,导入依赖的时候需要使用 < dependencyManagement > < / dependencyManagement > 如果说直接使用 <dependencies></dependencies> 就会出现 org.springframework.cloud:spring-cloud-starter-eureka :unknown的错误,所有只需要在外面加一个的标签并且还需要设置 Spring Milestones 仓库: < repositories > < repository > < id > spring - milestones < / id > < name > Spring Milestones < / name > < url > https : / / repo . spring . io /

Skipper https rest end point requests returning http urls

て烟熏妆下的殇ゞ 提交于 2020-03-05 03:10:29
问题 I am trying a poc with Spring cloud dataflow streams and have the the application iis running in Pivotal Cloud Foundry. Trying the same in kubernetes and the spring dataflow server dashboard is not loading.Debugged the issue and found the root cause is when the dashboard is loaded, its trying to hit the Skipper rest end point /api and this returns a response with the urls of other end points in skipper but the return urls are all in http. How can i force skipper to return https urls instead

Skipper https rest end point requests returning http urls

天涯浪子 提交于 2020-03-05 03:10:17
问题 I am trying a poc with Spring cloud dataflow streams and have the the application iis running in Pivotal Cloud Foundry. Trying the same in kubernetes and the spring dataflow server dashboard is not loading.Debugged the issue and found the root cause is when the dashboard is loaded, its trying to hit the Skipper rest end point /api and this returns a response with the urls of other end points in skipper but the return urls are all in http. How can i force skipper to return https urls instead

Spring Cloud 学习 (一) Eureka

天涯浪子 提交于 2020-03-04 08:28:35
微服务的功能主要有以下几个方面: 服务的注册和发现 服务的负载均衡 服务的容错 服务网关 服务配置的统一管理 链路追踪 实时日志 服务注册 是指向服务注册中心注册一个服务实例,服务提供者将自己的服务信息 (如服务名、IP 地址等) 告知服务注册中心。 服务发现 是指当服务消费者需要消费另外一个服务时,服务注册中心能够告知服务消费者它所要消费服务的实例信息(如服务名、IP 地址等)。通常情况下一个服务既是服务提供者,也是服务消费者。服务消费者一般使用 HTTP 协议或者消息组件这种轻量级的通信机制来进行服务消费。服务注册中心会提供服务的健康检查方案,检查被注册的服务是否可用。通常一个服务实例注册后,会定时向服务注册中心提供 “心跳”,以表明自己还处于可用的状态。当一个服务实例停止向服务注册中心提供心跳一段时间后,服务注册中心会认为该服务实例不可用,会将该服务实例从服务注册列表中剔 除。如果这个被剔除掉的服务实例过一段时间后继续向注册中心提供心跳,那么服务注册中心会将该服务实例重新加入服务注册中心的列表中。 Eureka 是一个用于服务注册和发现的组件,分为 Server (服务注册中心) 和 Client (服务提供者、服务消费者)。与 Eureka 类似得组件有 Consul 和 ZooKeeper。 Eureka 是 Spring Cloud 首选推荐的服务注册与发现组件,可以与

2020教你最新的Spring Cloud Ribbon 源码解析

此生再无相见时 提交于 2020-03-02 15:50:32
代码准备 依赖关系 +------------+ +------------+ | | | | | | | | | | | | | | | | | consumer +------------> | provider | | | RestTemplate | | | | | | | | | | | | | | +------------+ +------------+ pom 依赖 加入nacos 服务发现即可,内部引用了 spring-cloud-ribbon 相关依赖 <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> 调用客户端 我们这里以最简单的 RestTemplate 调用开始使用 Ribbon @Bean @LoadBalanced public RestTemplate restTemplate () { return new RestTemplate(); } // Controller 使用restTemplate 调用服务提供方接口 ResponseEntity<String> forEntity = restTemplate

01 Spring Cloud Config 实现配置中心

耗尽温柔 提交于 2020-02-29 23:44:00
Spring Cloud官网: https://spring.io/projects/spring-cloud 本篇主要讲 Spring Cloud Config ,参考内容如下: Spring Cloud Config 2.2.1.RELEASE参考文档 Spring Cloud Config 实现配置中心,看这一篇就够了 实现简单的配置中心 配置文件就在Spring官方提供的配置仓库:https://github.com/spring-cloud-samples/config-repo 1 创建配置中心服务端 完整代码参考: https://github.com/sxpujs/spring-cloud-examples/tree/master/config/config-server 1 新建Spring Boot项目,引入config-server <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> 2 配置config相关的配置项 bootstrap.yml spring: application: name: foo # 应用名 profiles: active: dev