spring-cloud

Spring @EnableResourceServer vs @EnableOAuth2Sso

此生再无相见时 提交于 2019-12-20 08:00:50
问题 Most of the tutorials I've read so far uses @EnableOAuth2Sso instead of @EnableResourceServer on the API gateway. What are the differences? What the OAuth2Sso does in contrast? Details: I'm implementing a security/infra architecture for spring-based microservices and single page apps. For some time, while we didn't have security requirements, the SPAs talked directly to open microservices, on different hosts (CORS party). Now I'm adding a layer of security and the gateway pattern using spring

Spring Boot with server.contextPath set vs. URL to hystrix.stream via Eureka Server

泄露秘密 提交于 2019-12-20 07:08:12
问题 I have Eureka Server with Turbine instance running and a few discovery clients that are connected to it. Everything works fine, but if I register a discovery client that has server.contextPath set, it didn't get recognized by InstanceMonitor and Turbine stream is not able to combine its hystrix.stream . This is how it looks in the logs of Eureka/Turbine server: 2015-02-12 06:56:23.265 INFO 1 --- [ Timer-0] c.n.t.discovery.InstanceObservable : Hosts up:3, hosts down: 0 2015-02-12 06:56:23.266

How to provide custom security configuration for oauth2 with spring-boot 1.3.0.RC1

混江龙づ霸主 提交于 2019-12-20 06:41:30
问题 With spring-cloud Angel.SR3 release I followed example in https://github.com/spring-cloud-samples/sso and things work fine with spring-boot 1.2.6.RELEASE. However with spring-boot 1.3.0.RC1, the oauth2 stuff has moved into spring-boot itself, and the code below fails to compile because class OAuth2SsoConfigurerAdapter no longer exists. What is the spring-boot only way to create equivalent configuration? public static void main(String[] args) { SpringApplication.run(MainAppApplication.class,

How to custom @FeignClient Expander to convert param?

本秂侑毒 提交于 2019-12-20 02:54:59
问题 Feign default expander to convert param: final class ToStringExpander implements Expander { @Override public String expand(Object value) { return value.toString(); } } I want custom it to convert user to support GET param, like this @FeignClient("xx") interface UserService{ @RequestMapping(value="/users",method=GET) public List<User> findBy(@ModelAttribute User user); } userService.findBy(user); What can i do? 回答1: First,you must write a expander like ToJsonExpander : public class

Spring Cloud Stream and @Publisher annotation compatiblity

我是研究僧i 提交于 2019-12-20 02:40:09
问题 Since Spring Cloud Stream has not an annotation for sending a new message to a stream (@SendTo only works when @StreamListener is declared), I tried to use Spring Integration annotation for that purpose, that is @Publisher. Because @Publisher takes a channel and @EnableBinding annotations of Spring Cloud Stream can bind an output channel using @Output annotation, I tried to mix them in the following way: @EnableBinding(MessageSource.class) @Service public class ExampleService { @Publisher

Disable Cloudformation in Spring Cloud AWS

一个人想着一个人 提交于 2019-12-19 13:02:47
问题 How can I disable the Cloudformation in a spring boot app that using spring cloud AWS? I keep getting this error when running my app on amazon: ... Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.env.stack.config.StackResourceRegistryFactoryBean]: Factory method 'stackResourceRegistryFactoryBean' threw exception; nested exception is com.amazonaws.AmazonServiceException: Stack for i-b5ce9e32 does not exist (Service:

Understanding Spring Cloud Eureka Server self preservation and renew threshold

杀马特。学长 韩版系。学妹 提交于 2019-12-19 12:02:04
问题 I am new to developing microservices, although I have been researching about it for a while, reading both Spring's docs and Netflix's. I have started a simple project available on Github. It is basically a Eureka server (Archimedes) and three Eureka client microservices (one public API and two private). Check github's readme for a detailed description. The point is that when everything is running I would like that if one of the private microservices is killed, the Eureka server realizes and

Overriding Zuul Filter SendErrorFilter

主宰稳场 提交于 2019-12-19 11:16:38
问题 The class org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter handles error responses. I would like to override this filter to do a custom response instead of the ZuulException while forwarding etc. How can I replace this with my own version? Just write and register? Would that do it or is there something else needed? 回答1: all you need to do is create a ZuulFilter and expose it as an @Bean . It needs to be in order before SendErrorFilter which is set to 0 . You might need to

Refresh of Zuul configuration when using Spring Config Service

a 夏天 提交于 2019-12-19 10:49:27
问题 We have a Zuul proxy (wraped with Spring Cloud/Boot) deployed that fetches configuration from the Spring Config Server. Every time I do changes in the routes I restart Zuul application and I wonder if there is a better approach that can be taken (like refresh of Zuul config information)? :) Thank you, 回答1: You can issue a refresh command via rest: curl -X POST http://<host>:<port>/refresh I wrote a simple bash script that commits all my changes to the config file in the Git repository and

Can I generate a Spring Feign client with Multipart parameters?

北城余情 提交于 2019-12-19 07:32:15
问题 I am getting the error: "Method has too many Body parameters" when trying to generate a Spring Feign client @RequestMapping(value="/media", method=RequestMethod.POST) String uploadMedia(@RequestHeader("Authentication") String token, @RequestPart("media") MultipartFile audio, @RequestPart("a-json-object") SomeClass someClazz, @RequestPart("another-json-object") AnotherClass anotherClazz); I found the following solution, which works when using regular Feign annotations, but not with Spring MVC