Tag: spring cloud

java.lang.IllegalStateException:org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient中没有可用于学生服务的实例

我从link :: https://howtodoinjava.com/spring/spring-cloud/consul-service-registration-discovery/运行Spring Cloud Consule示例。 当我运行http:// localhost:8098 / getSchoolDetails / abcschool我收到以下错误,似乎客户端无法识别student-service 。 java.lang.IllegalStateException: No instances available for student-service at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:75) ~[spring-cloud-netflix-core-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor.intercept(LoadBalancerInterceptor.java:55) ~[spring-cloud-commons-1.2.2.RELEASE.jar:1.2.2.RELEASE] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.cloud.netflix.metrics.MetricsClientHttpRequestInterceptor.intercept(MetricsClientHttpRequestInterceptor.java:64) ~[spring-cloud-netflix-core-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:70) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:559) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE] at com.example.howtodoinjava.springcloudconsulschool.delegate.StudentServiceDelegate.callStudentServiceAndGetData(StudentServiceDelegate.java:22) ~[classes/:na] at […]

Spring Boot,Spring Cloud AWS和AWS SQS无法从队列中读取

我正在尝试使用Spring Boot和Spring Cloud AWS SQS构建一个最小的gradle java项目,但我无法从队列中读取它。 这些是我的项目文件: 的build.gradle: apply plugin: “java” apply plugin: “eclipse” apply plugin: “spring-boot” apply plugin: “io.spring.dependency-management” sourceCompatibility = 1.8 targetCompatibility = 1.8 buildscript { repositories { mavenCentral() } dependencies { classpath(“org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE”) classpath(“io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE”) } } dependencyManagement { imports { mavenBom(“org.springframework.cloud:spring-cloud-aws:1.1.0.RELEASE”) } } repositories { mavenCentral() } dependencies { compile(“org.springframework.boot:spring-boot-starter-actuator:1.3.5.RELEASE”) compile(“org.springframework.cloud:spring-cloud-starter-aws:1.1.0.RELEASE”) // if […]

尤里卡检测服务状态

上下文 我们使用Spring Cloud Netflix和Eureka作为服务发现,使用Zuul代理服务并对它们进行负载均衡。 微服务使用NodeJS实现,并使用NPM模块eureka-js-client在Eureka上注册,其间有一个自定义层,用于处理配置和所有微服务通用的内容。 问题 问题是Eureka无法识别是否有一项服务出现问题。 这是一个问题,因为我们正在拥有一个具有自动部署的开发基础架构,每次重新部署并重新启动不同端口上的微服务而无需重新启动Eureka(和Zuul)。 因此,过了一段时间,我们有一个微服务的十个或更多实例,其中只有一个上升,但所有被认为是上升。 解决方法 我尝试在客户端上设置heartbeatInterval较小,但这没有帮助。 我尝试在服务器上设置renewalThresholdUpdateIntervalMs较小,但这也无济于事。 更多令人沮丧,无助的财产尝试…… 题 如何在合理的时间内(不是30分钟左右)配置Eureka以驱逐实例或将状态设置为DOWN不发送心跳的实例? 代码片段 服务器本身不包含可提及的代码(只需几个注释即可使用Spring Cloud Starter启动Eureka服务器)。 Eureka服务器的配置(我删除了所有非工作尝试): server: port: 8761 spring: cloud: client: hostname: localhost eureka: instance: address: 127.0.0.1 hostname: ${spring.cloud.client.hostname} 发送到服务器的客户端配置(使用eureka-js-client ): { instance : { instanceId : `${CONFIG.instance.address}:${CONFIG.instance.name}:${CONFIG.instance.port}`, app : CONFIG.instance.name, hostName : CONFIG.instance.host, ipAddr : CONFIG.instance.address, port : { […]

ossoprovider.endpoint.TokenEndpoint:处理错误:InvalidGrantException,错误的凭据

我正在开发Spring Cloud授权服务器 ,启动服务器时没有收到任何错误,但是当我尝试访问http:// localhost:9000 / services / oauth / token时 ,我收到以下错误。 你能指导一下这个问题吗? 虽然grant_type是正确的,但我想知道为什么说无效补助金? PluralsightSpringcloudM4SecureauthserverApplication @SpringBootApplication @EnableAuthorizationServer @EnableResourceServer @RestController public class PluralsightSpringcloudM4SecureauthserverApplication { public static void main(String[] args) { SpringApplication.run(PluralsightSpringcloudM4SecureauthserverApplication.class, args); } @RequestMapping(“/user”) public Principal user(Principal user) { return user; } } ServiceConfig @Configuration public class ServiceConfig extends GlobalAuthenticationConfigurerAdapter { @Override public void init(AuthenticationManagerBuilder auth) throws […]

在Spring Config Server中添加环境存储库

我是Spring Boot的新手,所以如果我忽视了一些简单的事情,请原谅。 使用Spring Config Server,您可以通过.yml文件指定您想要使用的环境存储库类型(native,Git等)。 这些环境存储库包含在第三方依赖项中。 我想知道是否可以添加自己的环境存储库,以便您可以连接到数据库以获取配置? 提前谢谢了!

使用OAuth2和JWT的Spring Security:编码的密码看起来不像BCrypt

我正在尝试使用JWT实现Spring AuthorizationServer。 我能够生成JWT令牌并登录,直到我将BCrypt添加到混音中。 现在,当我尝试登录时,我从API获得“错误凭据”。 OAuth2Configuration.java @Configuration @EnableAuthorizationServer public class OAuth2Configuration extends AuthorizationServerConfigurerAdapter { private DataSource dataSource; private AuthenticationManager authenticationManager; private BCryptPasswordEncoder passwordEncoder; public OAuth2Configuration(AuthenticationManager authenticationManager) { this.authenticationManager = authenticationManager; this.dataSource = new Jdbc3PoolingDataSource(); this.passwordEncoder = new BCryptPasswordEncoder(); } @Override public void configure(AuthorizationServerSecurityConfigurer security) throws Exception { security.passwordEncoder(passwordEncoder); } @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception […]

Spring Cloud Config Server环境变量优先级

在使用spring cloud配置服务器时,我对环境变量的优先级有疑问 在我的服务中,我有一个带有此内容的本地属性文件application.yml foo: bar: “some” buz: “some” joe: “some” 该服务还连接到配置服务器,配置存储库包含文件testservice-api.yml (其中testservice-api是服务的spring应用程序名称)。 该文件的内容是: foo: bar: “some-specific” 因此,使用此设置,运行时的配置将导致: { “foo.bar”: “some-specific”, “foo.buz”: “some”, “foo.joe”: “some” } 现在我尝试用环境变量覆盖foo.bar和foo.joe 。 所以我用这个命令启动服务: FOO_BAR=some-env FOO_JOE=some-env gradle bootRun 从我在spring boot文档的这一部分中读到的内容 ,环境变量应优先于配置文件 – spring cloud配置文档也没有说明不同 – 所以我希望结果如下: { “foo.bar”: “some-env”, “foo.buz”: “some”, “foo.joe”: “some-env” } 但相反,我得到: { “foo.bar”: “some-specific”, “foo.buz”: “some”, “foo.joe”: […]

Spring @EnableResourceServer vs @ EnableOAuth2Sso

到目前为止,我读过的大多数教程都在API网关上使用@EnableOAuth2Sso而不是@EnableResourceServer 。 有什么区别? 相比之下, OAuth2Sso作用是什么? 详细信息:我正在为基于Spring的微服务和单页应用程序实现安全/基础架构。 有一段时间,虽然我们没有安全要求,但SPA直接与不同主机(CORS方)上的开放式微服务进行了对话。 现在我使用spring-oauth和spring-zuul添加一层安全性和网关模式。 所以我有@EnableAuthorizationServer的服务(uaa-service)和@EnableAuthorizationServer和@EnableAuthorizationServer的网关。 我只需要密码授权类型,因此每个SPA都有自己的登录表单,并通过网关对uaa-service令牌端点进行身份validation,然后继续使用该令牌进行进一步的请求。 这种方法有什么问题吗? 我应该使用@EnableOAuth2Sso吗?

将Spring Cloud与Orchestration工具一起使用,如Docker Swarm和Kubernetes

我有一个云原生应用程序,它是使用Spring Cloud Netflix 。 所以在我的应用程序中,我正在使用Eureka服务发现来管理应用程序的不同服务的所有实例。 当每个服务实例想要与另一个服务实例通信时,它使用Eureka获取有关目标服务的所需信息(例如,ip和port)。 服务编排也可以使用Docker Swarm和Kubernetes等工具实现,看起来Eureka和Docker Swarm和Kubernetes之间存在一些重叠。 例如,想象一下,我在Docker Swarm创建了一个具有5个实例的服务,并且swarm确保这5个实例始终正常运行。 此外,该应用程序的每项服务都在内部向Eureka发送定期心跳,以表明它仍然存在。 看起来我们有两层健康检查,一个用于Docker ,另一个用于Spring Cloud本身。 或者,例如,您可以在整个swarm中公开服务的端口,这消除了一些服务发现的需求(端口始终是明显的)。 另一个例子可能是由docker中的routing mesh执行的负载平衡,以及由Ribbon组件或Eureka本身在内部发生的负载平衡。 在这种情况下,具有硬件负载平衡器,引导我们到3层负载平衡系统。 所以我想知道将这些工具一起使用是否合理? 似乎使用这些技术的组合会极大地增加应用程序的复杂性并且可能是多余的。 谢谢你的阅读!

在Spring Cloud AWS中禁用Cloudformation

如何在使用Spring Cloud AWS的Spring启动应用程序中禁用Cloudformation? 在亚马逊上运行我的应用程序时,我一直收到此错误: … 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: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: 75b3076a-176d-11e6-90cc-b55a643dc6d6) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) … 82 more Caused by: com.amazonaws.AmazonServiceException: Stack for i-b5ce9e32 does not exist (Service: […]