spring-cloud

File upload spring cloud feign client

非 Y 不嫁゛ 提交于 2020-01-01 07:21:32
问题 When make a post request from one microservice to another using feign client of spring cloud netflix, I get the following error in Postman : { "timestamp": 1506933777413, "status": 500, "error": "Internal Server Error", "exception": "feign.codec.EncodeException", "message": "Could not write JSON: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is

Is there a way to use Spring Cloud {cipher} in Spring Boot application config?

人盡茶涼 提交于 2020-01-01 04:12:08
问题 I have a Spring Boot app that is using Spring Cloud Config but I would like to encrypt the Spring Cloud Config password in the Spring Boot apps bootstrap.yml file. Is there a way to do this? Below is an example. Spring Boot app bootstrap.yml spring: cloud: config: uri: http://locahost:8888 username: user password: '{cipher}encryptedpassword' 回答1: A couple things I've discovered related to this. If you use bootstrap.yml (or application.yml), the format for the cipher text must enclosed within

How to Set Request Headers Using a Feign Client?

两盒软妹~` 提交于 2020-01-01 03:29:12
问题 We are developing a suite of Microservices using Spring Cloud framework and one of the the things that we need to do is to set request headers. I know I can pass a parameter @RequestHeader to a Feign method but the value needs to come from another bean. I don't know if SPEL can be used for a Feign param value. I was thinking that this is a common enough use case for most clients so there'd be some examples, but so far I've not found any. Of course I can dig through the Spring course code and

RefreshScope Runtime Configuration Without Spring Cloud Config Server

女生的网名这么多〃 提交于 2019-12-31 04:15:09
问题 Is it possible to refresh property(api-url) through POST rest api /refresh call using @RefreshScope without having setup of spring cloud config server and spring cloud config client setup. for.e.g Consumer.java @Service public class Consumer { @value(${api-url}) private String apiUrl; api-url is getting read from application.yml now. I want to change the api-url at runtime without restarting server. Is it possible in spring boot? 回答1: Yes, just include spring cloud starter <parent> <groupId

Oauth2 client logout doesn't work

只愿长相守 提交于 2019-12-30 11:06:16
问题 I try to use the approach, described here https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_logout : So I have following backend codebase: @EnableAutoConfiguration @Configuration @EnableOAuth2Sso @Controller public class ClientApplication extends WebSecurityConfigurerAdapter { private Logger logger = LoggerFactory.getLogger(ClientApplication.class); @RequestMapping("/hello") public String home(Principal user, HttpServletRequest request, HttpServletResponse response, Model

How to add some data in body of response for Cloud Api Gateway

霸气de小男生 提交于 2019-12-30 09:49:59
问题 I'm adding some auth logic into cloud api gateway. I've added GatewayFilter: import java.util.List; import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.http.HttpStatus; import org.springframework.util.CollectionUtils; import org.springframework.util.PatternMatchUtils; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; public class

Request 'OPTIONS /logout' doesn't match 'POST /logout

ぃ、小莉子 提交于 2019-12-30 06:18:09
问题 I am studying Spring Cloud and Spring OAuth2 by decomposing the three interconnected apps in this GitHub sample. When I open up the /oauth/revoke-token endpoint in the authserver app and then call it from the ui app with a http://localhost:9999/uaa/logout , the debug log for the authserver app gives the following error message while rejecting the logout request: Request 'OPTIONS /logout' doesn't match 'POST /logout What specific changes need to be made to the code in the sample GitHub apps in

Spring Cloud - Getting Retry Working In RestTemplate?

时光毁灭记忆、已成空白 提交于 2019-12-30 05:02:05
问题 I have been migrating an existing application over to Spring Cloud's service discovery, Ribbon load balancing, and circuit breakers. The application already makes extensive use of the RestTemplate and I have been able to successfully use the load balanced version of the template. However, I have been testing the situation where there are two instances of a service and I drop one of those instances out of operation. I would like the RestTemplate to failover to the next server. From the

Why is ZUUL forcing a SEMAPHORE isolation to execute its Hystrix commands?

无人久伴 提交于 2019-12-30 01:21:04
问题 I noticed Spring-Cloud ZUUL forces the execution isolation to SEMAPHORE instead of the THREAD defaults (as recommended by Netflix). A comment in org.springframework.cloud.netflix.zuul.filters.route.RibbonCommand says: we want to default to semaphore-isolation since this wraps 2 others commands that are already thread isolated But still I don't get it :-( What are those two other commands? Configured this way, Zuul can only sched load but does not allow for timing out and let the client walk

Spring Cloud Feign with OAuth2RestTemplate

故事扮演 提交于 2019-12-30 00:41:27
问题 I'm trying to implement Feign Clients to get my user info from the user's service, currently I'm requesting with oAuth2RestTemplate, it works. But now I wish to change to Feign, but I'm getting error code 401 probably because it doesn't carry the user tokens, so there is a way to customize, if Spring support for Feign is using, a RestTemplate so I can use my own Bean? Today I'm implementing in this way The service the client @Retryable({RestClientException.class, TimeoutException.class,