spring-cloud

Spring Cloud Contract issues retrieving stubs from Artifactory

时光毁灭记忆、已成空白 提交于 2019-12-05 21:36:58
I have tests for two consumers and a producer working fine offline but the consumer tests fail when I change them for retrieving the stubs from Artifactory. This is the code for working offline: @RunWith(SpringRunner.class) @SpringBootTest(classes = ContractTestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) @AutoConfigureStubRunner(ids = {"com.mycompany:service-name:+:stubs"}, workOffline = true) @ImportAutoConfiguration(org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration.class) @DirtiesContext public class MyContractTest And this is for

Spring redirect url issue when behind Zuul proxy

烈酒焚心 提交于 2019-12-05 20:27:17
问题 I've been trying to get to the bottom of a strange redirection issue for the past 2 days without success. Based on the spring-cloud example projects, I've configured Eureka, Zuul and a basic service that runs behind Zuul. I have the following method; @RequestMapping(method = RequestMethod.POST, value = "/register") public String registerDevice(Principal principal, String response) { // ... return "redirect:/account"; } The form is setup to post to the proxied URL as follows; POST https:/

Microservices - RestTemplate UnknownHostException

孤街浪徒 提交于 2019-12-05 18:58:06
I have a simple setup with a Eureka service registration server, a service for the public API and a service that gets called from the public API using RestTemplate. Eureka tells me that the services are successfully registered, but when I call the service @Service public class MyServiceService { @Autowired private RestTemplate restTemplate; private final String serviceUrl; public MyServiceService() { this.serviceUrl = "http://MY-SERVICE"; } public Map<String, String> getTest() { Map<String, String> vars = new HashMap<>(); vars.put("id", "1"); restTemplate.setRequestFactory(new

How to disable eureka lookup on specific @FeignClient

跟風遠走 提交于 2019-12-05 17:38:09
I have a microservice that uses @FeignClient predominantly to talk to other micro-services. This works beautifuly using Eureka's service discovery mechanism. Now I have a pressing need to use a @FeignClient to connect to an external system and still perform load balancing using configurations as shown below. Feign client : @FeignClient("externalServers") public interface ExternalServersClient { @RequestMapping(method = RequestMethod.GET, value = "/someExternalUrl") ResponseEntity<Object> callExternalServer(); } application.yml : externalServers: ribbon: listOfServers: server1:18201,server2

spring-boot Autowired DiscoveryClient RestTemplate UnknownHostException

喜夏-厌秋 提交于 2019-12-05 16:25:11
I'm using spring boot 1.3.3 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> Edit I'm using Brixton.RC1 for my spring cloud dependencies <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.RC1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> My Application is setup with these

Multiple Spring Cloud Functions in one project for deployment on AWS Lambda

痴心易碎 提交于 2019-12-05 15:28:20
I could need some help here... I'm using Spring Cloud Function, and I want to deploy my functions on AWS Lambda, using the adapter for AWS. My application class looks like this: package example; @SpringBootApplication public class SpringCloudFunctionApiGatewayApplication { public static void main(String[] args) { SpringApplication.run(SpringCloudFunctionApiGatewayApplication.class, args); } } Function 1 looks like this: package example; @Component public class StoreFunction implements Consumer<Message<DemoEntity>>{ @Override public void accept(Message<DemoEntity> t) { System.out.println(

Best way to propagate credentials between micro services using spring-session

▼魔方 西西 提交于 2019-12-05 14:59:48
We are using an architecture very similar to the one described in this great guide on spring.io . Our gateway handles authentication, and sessions are stored in Redis using spring-session. Endpoints of our micro services are secured and also use spring-session. In a micro service I need to call an endpoint of another micro service. I get the URL easily through the discovery client, but I need to provide credentials and I'm not sure of the best way to achieve that. I am thinking about getting the SESSION cookie from the HttpRequest, store it in some kind of thread local variables or request

什么是 Spring Cloud Gateway

雨燕双飞 提交于 2019-12-05 10:04:28
什么是 Spring Cloud Gateway Spring Cloud Gateway 是 Spring 官方基于 Spring 5.0,Spring Boot 2.0 和 Project Reactor 等技术开发的网关,Spring Cloud Gateway 旨在为微服务架构提供一种简单而有效的统一的 API 路由管理方式。 Spring Cloud Gateway 作为 Spring Cloud 生态系中的网关,目标是替代 Netflix ZUUL ,其不仅提供统一的路由方式,并且基于 Filter 链的方式提供了网关基本的功能,例如:安全,监控/埋点,和限流等。 # Spring Cloud Gateway 功能特征 基于 Spring Framework 5,Project Reactor 和 Spring Boot 2.0 动态路由 Predicates 和 Filters 作用于特定路由 集成 Hystrix 断路器 集成 Spring Cloud DiscoveryClient 易于编写的 Predicates 和 Filters 限流 路径重写 # Spring Cloud Gateway 工程流程 客户端向 Spring Cloud Gateway 发出请求。然后在 Gateway Handler Mapping 中找到与请求相匹配的路由,将其发送到

创建统一的依赖管理

人盡茶涼 提交于 2019-12-05 10:02:36
概述 温馨提示 当前 Spring Cloud Alibaba 的 0.2.1.RELEASE 版本基于 Spring Cloud Finchley(F)开发,故在选择 Spring Boot 版本时不要使用 2.1.0 及以上版本(因为 2.1.x 版本必须使用 Spring Cloud Greenwich,俗称 G 版),请使用官方 Demo 中使用的 2.0.6.RELEASE,以免发生意想不到的问题(比如服务无法注册到服务器) Spring Cloud Alibaba 项目都是基于 Spring Cloud,而 Spring Cloud 项目又是基于 Spring Boot 进行开发,并且都是使用 Maven 做项目管理工具。在实际开发中,我们一般都会创建一个依赖管理项目作为 Maven 的 Parent 项目使用,这样做可以极大的方便我们对 Jar 包版本的统一管理。 # 创建依赖管理项目 创建一个工程名为 hello-spring-cloud-alibaba-dependencies 的项目, pom.xml 配置文件如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001

分布式配置中心服务端

纵然是瞬间 提交于 2019-12-05 10:01:59
概述 创建一个工程名为 hello-spring-cloud-config 的项目, pom.xml 配置文件如下: <?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> <parent> <groupId>com.snake</groupId> <artifactId>hello-spring-cloud-dependencies</artifactId> <version>1.0.0-SNAPSHOT</version> <relativePath>../hello-spring-cloud-dependencies/pom.xml</relativePath> </parent> <artifactId>hello-spring-cloud-config</artifactId>