首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >祖尔与领事整合问题

祖尔与领事整合问题
EN

Stack Overflow用户
提问于 2015-11-18 14:38:48
回答 1查看 3.4K关注 0票数 1

我在使用Zuul和领事服务发现设置Spring应用程序时遇到了问题。我在本地安装和运行了领事服务器代理:

代码语言:javascript
复制
./src/main/bash/local_run_consul.sh

当我使用@EnableZuulProxy注释运行Spring应用程序时,我得到以下错误:

代码语言:javascript
复制
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.netflix.zuul.filters.RouteLocator]: Factory method 'routeLocator' threw exception; nested exception is java.lang.IllegalStateException: Unable to locate service in consul agent: edge-server-8765
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 73 more

资料来源:

build.gradle

代码语言:javascript
复制
buildscript {
    ext {
        springBootVersion = '1.2.7.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'war'
apply plugin: 'spring-boot'

war {
    baseName = 'edge-server'
    version = '0.0.1-SNAPSHOT'
}

mainClassName = 'com.akamai.pulsar.onboarding.edge.app.ZuulApplication'

dependencies {
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")

    compile("org.springframework.boot:spring-boot-starter-web") {
        exclude module: 'spring-boot-starter-tomcat'
    }
    compile("org.springframework.boot:spring-boot-starter-undertow")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile('org.springframework.cloud:spring-cloud-starter-zuul:1.0.0.RELEASE')
    compile('org.springframework.cloud:spring-cloud-starter-consul-all:1.0.0.M3')

    testCompile('org.springframework.boot:spring-boot-starter-test')
}

application.yml

代码语言:javascript
复制
info:
  component: Zuul Server

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

zuul:
  ignoredServices: "*"
  routes:
    test-api:
      path: /test-api/**

server:
  port: 8765

logging:
  level:
    ROOT: INFO
    org.springframework.web: INFO

bootstrap.yml

代码语言:javascript
复制
spring:
  application:
    name: edge-server
  cloud:
    consul:
      host: localhost
      port: 8500
      config:
        enabled: true

ZuulApplication.java

代码语言:javascript
复制
@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
public class ZuulApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder(ZuulApplication.class).web(true).run(args);
    }
}

备注:当我注释掉@EnableZuulProxy注释时,我的服务没有问题地运行,并在领事中正确注册。

我不知道该怎么办。也许有一些坏的依赖问题?

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-18 20:28:32

春季云中有一个错误ConsulDiscoveryClient.getLocalServiceInstance

现在,设置zuul.ignoreLocalService: false将围绕着它工作。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33782873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档