标签: spring-cloud

Eureka - 无法得到回复 - 无法联系任何eureka节点

我有一个在端口8761(localhost:8761/eureka)上运行的Eureka服务器,我有一个Zuul应用程序,我想在eureka注册,但我一直得到同样的错误:

Can't get a response from http://localhost:8761/eurekaapps/ZUULSERVER
Can't contact any eureka nodes - possibly a security group issue?

java.lang.RuntimeException: Bad status: 404
        at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1155)
        at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1060)
        at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:606)
        at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1596)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)

这是zuul应用程序的application.yml:

info:
  component: Zuul Server

eureka:
  server:
    enabled: true
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka
    registerWithEureka: true
    fetchRegistry: false  

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true
  health:
    sensitive: false

zuul:
  route:
    discovery:
      url: http://localhost:9000/polaris/discovery 
      path: /polaris/discovery/**
    sla:
      url: http://localhost:9000/polaris/sla
      path: /polaris/sla/**
    stores: …
Run Code Online (Sandbox Code Playgroud)

netflix spring-cloud netflix-eureka netflix-zuul

4
推荐指数
1
解决办法
1万
查看次数

spring-cloud:在一个容器中部署两个eureka客户端时出错

我有两个服务是eureka客户端(使用@EnableDiscoveryClient).两种服务都打包在单独的war文件中.在部署时(单个tomcat容器),部署了一个服务,但在部署第二个服务期间,抛出了以下错误

==============记录===================================

[2015-01-28 19:11:01.030] boot - 6832 ERROR [localhost-startStop-1] --- SpringApplication: Application startup failed
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.springframework.cloud.context.environment.EnvironmentMana
ger@ca848c] with key 'environmentManager'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.cloud.context.envi
ronment:name=environmentManager,type=EnvironmentManager
        at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:613)
        at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:538)
        at org.springframework.jmx.export.MBeanExporter.afterSingletonsInstantiated(MBeanExporter.java:420)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:782)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
        at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
        at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
        at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5185)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:917)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1701)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745) …
Run Code Online (Sandbox Code Playgroud)

spring-cloud

4
推荐指数
1
解决办法
2984
查看次数

使用配置文件禁用Spring Cloud Server配置?

我想实现以下目标:

  • 在'dev'模式下,在当前的webapp中嵌入Spring Cloud Config
  • 如果不处于"dev"模式,请连接到已运行的Spring Cloud Config服务器实例

因此,我当前webapp的类路径包含配置服务器和客户端的依赖项:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-config-server</artifactId>
</dependency> 
Run Code Online (Sandbox Code Playgroud)

在开发模式下,并且在bootstrap.yml中具有以下属性,它就可以了(嵌入式配置服务器已配置并启动)

spring:
  application:
    name: app1
  profiles:
    active: dev
  cloud:
    config:
      uri: ${SPRING_CONFIG_URI:http://localhost:8888}

---

spring:
  profiles: dev
  cloud:
    config:
      server:
        bootstrap: true
        git:
          uri: https://github.com/nocquidant/my-config-repo.git
          basedir: target/config
Run Code Online (Sandbox Code Playgroud)

当不在'dev'模式时(例如spring.profiles.active = prod),当前的webapp没有启动:它无法自动装配我的属性(我想嵌入式服务器是在配置错误的情况下启动的)

如果我在POM中评论spring-cloud-config-server依赖关系,那么它可以工作.

我认为我可以使用以下内容实现我想要的,但是没有(实际上使用EnableConfigServer或者似乎没有改变任何东西):

@Configuration
@Profile("dev")
@EnableConfigServer
public static class EmbeddedConfigServer { }
Run Code Online (Sandbox Code Playgroud)

我该怎么办(不使用maven配置文件)?有没有一种简单的方法来禁用spring cloud配置服务器?有没有更好的方法来实现我的目标?

任何帮助赞赏.

PS版使用:

<parent>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-parent</artifactId>
  <version>1.0.3.BUILD-SNAPSHOT</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

//尼克

// ---编辑#1

请参阅github上的一个简单项目:https://github.com/nocquidant/exchange/tree/master/poc-spring-cloud/

它包含2个简单的模块:config-server和client-app.

首先,如果从客户端应用程序模块启动Client类,则一切正常(嵌入模式打开=>请参阅bootstrap.yml中的dev配置文件)

然后,启动config-server(ConfigServer类).然后在客户端应用程序中将'spring.profiles.active'更改为'prod'(或其他)并重新启动它:属性注入不再起作用(并且webapp拒绝启动).

Caused …
Run Code Online (Sandbox Code Playgroud)

spring-cloud

4
推荐指数
1
解决办法
4012
查看次数

执行应用程序时未使用application.yml中的spring.cloud.config设置

我对Spring Cloud有问题:执行应用程序时未使用我在spring.cloud.config的application.yml中的设置。让我在这里详细说明。我希望我的服务可以从远程ConfigServer获取设置。我已将ConfigServer创建为带有@EnableConfigServer批注的春季启动应用程序。之后,我用下一个配置文件创建了客户端应用程序:

    application:
      name: mw
    cloud:
      config:
        enabled: true
        uri: http://172.17.42.1:8888
        fail-fast: true
Run Code Online (Sandbox Code Playgroud)

主类:

    @EnableEurekaClient
    @SpringBootApplication
    public class MwApplication
Run Code Online (Sandbox Code Playgroud)

并在应用程序中进行额外配置:

    @Configuration
    @EnableJpaRepositories(basePackages = {"com.sample.repository"})
    @EnableTransactionManagement
    @EnableScheduling
    public class AppConfiguration
Run Code Online (Sandbox Code Playgroud)

我还有下一个依赖项:

    spring-cloud-starter-eureka
    spring-cloud-config-client
    spring-boot-configuration-processor
    spring-boot-starter-data-jpa
Run Code Online (Sandbox Code Playgroud)

当我执行我的客户端应用程序时,我收到以下消息:ConfigServicePropertySourceLocator:无法找到PropertySource:GET请求“ http:// localhost:8888 / mw / default ” 上的I / O错误

该应用程序尝试从默认uri(localhost)获取数据,而不是从我的设置中使用uri。我已经在调试模式下查看了应用程序,看到org.springframework.cloud.config.client.ConfigServiceBootstrapConfiguration正在使用默认属性创建ConfigClientProperties,并且未使用来自application.yml的设置。

我究竟做错了什么?谢谢。

java spring spring-boot microservices spring-cloud

4
推荐指数
1
解决办法
8688
查看次数

从在GitHub上托管的Spring Cloud Config Server访问的repo的身份验证问题

我在GitHub上的repo中托管配置.如果我保持回购公众的一切都很好,但如果我把它私有化我面对:

org.eclipse.jgit.errors.TransportException: 
 https://github.com/my-user/my-repo:
 Authentication is required but no CredentialsProvider has been registered
Run Code Online (Sandbox Code Playgroud)

我用来定位回购的属性是

spring.cloud.config.server.git.uri=https://github.com/my-user/my-repo
Run Code Online (Sandbox Code Playgroud)

我应该怎么做才能正确配置私人仓库,谢谢

spring github spring-boot spring-cloud spring-cloud-config

4
推荐指数
1
解决办法
4354
查看次数

功能区负载均衡算法

我在我的微服务项目中使用Spring Cloud和NetflixOSS.此外,我使用带有Feign Client的功能区作为我的客户端负载均衡器.我想知道,有没有可能为Ribbon实现或选择不同类型的负载平衡算法?因为据我所知,默认是循环法.

提前致谢!

spring load-balancing spring-boot spring-cloud spring-cloud-netflix

4
推荐指数
1
解决办法
2485
查看次数

使用环境变量设置Hystrix超时

要更改Hystrix的默认请求超时(1000毫秒),必须设置以下属性: hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000

相应的环境变量是什么?

我想在我最喜欢的云平台上"调整"超时,而不首先触及源代码.我很确定这个不起作用:HYSTRIX_COMMAND_DEFAULT_EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS=2000


编辑:Spring Cloud Camden/Spring Boot 1.4发现问题.

hystrix spring-cloud spring-cloud-netflix

4
推荐指数
2
解决办法
7076
查看次数

什么是春天尤里卡的instanceid?

我读到Eureka客户端的实例ID必须是唯一的,当我们希望运行同一个Eureka Client的多个实例时,我们添加了这个属性:

eureka.instance.instance-id==${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${random.value}}
Run Code Online (Sandbox Code Playgroud)

实例Id的意义是什么?上述行如何重要?

spring spring-cloud netflix-eureka

4
推荐指数
2
解决办法
5257
查看次数

使用Spring Boot的微服务中的安全问题

我在春季启动(和一般)的微服务中误解了安全性.我想使用Spring框架和微服务构建一个项目,但在架构规划中我陷入了困境.微服务中的安全性应该如何?在我看来,在所有项目中应该是一个组件,所有请求都抛出组件并传播到其他组件.我可以找到它是Spring Cloud Zuul,它是微服务中的api网关,我有想法制作一个响应网关的项目,并在组件中增加安全性.我的意思是它将类似于包含Spring Cloud Zuul,Spring Security,Spring Data JPA依赖项的项目.您认为提供安全性的好方法如何?有可能建立这样的东西吗?

java spring spring-mvc spring-security spring-cloud

4
推荐指数
1
解决办法
1035
查看次数

带有Java和Spring的AWS Kinesis使用者

我想在Spring启动应用程序中编写一个AWS kinesis流使用者。而且我不确定Spring是否支持kinesis,还是必须使用kinesis客户端库。

根据此博客文章的介绍 org.springframework.integration:spring-integration-aws(RELEASE在maven repo中可用)。但是,此示例在GitHub上使用,该示例org.springframework.cloud:spring-cloud-starter-stream-kinesis仅在的Spring快照repo中可用1.0.0.BUILD-SNAPSHOT。

编辑:问题是,在哪里可以找到示例KinesisMessageDrivenChannelAdapter?

spring amazon-web-services amazon-kinesis spring-cloud spring-cloud-stream

4
推荐指数
1
解决办法
2905
查看次数