无法解析值“ $ {zuul.prefix}”中的占位符“ zuul.prefix”

时间:2018-11-16 09:56:19

标签: spring-boot netflix-zuul spring-cloud-config

我有一个项目,其中包含网关服务器(Zuul)和eureka服务器的微服务,并集成了配置服务器。

我有一个git存储库,其中包含网关服务器(gateway-server-dev.yml)的属性文件

gateway-server-dev.yml文件:

Example.prototype.go = function() {
  console.log("going");
};
(new Example());

网关服务器中的引导文件为:

    spring:
    application:
    name: gateway-server

 info:
  component: Gateway Server

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



  zuul:
 prefix: /CustomerHub/api
 routes:
   create-customer: 
      path: /create/**
     serviceId: create-customer
   search-customer: 
     path: /search/**
     serviceId: search-customer
   update: 
      path: /update/**
     serviceId: update-customer
   authorization:
     path: /authorization/**
     sensitiveHeaders:
     serviceId: customerhub-authorization      
  host:
       connect-timeout-millis: 5000
       socket-timeout-millis: 10000
        max-total-connections: 10000
       max-per-route-connections: 50
 ribbon:
   eager-load:
     enabled: true

   ribbon:
 ReadTimeout: 60000
 ConnectTimeout: 60000
 MaxAutoRetries: 3
 MaxAutoRetriesNextServer: 3
 restclient:
 enabled: true
      eureka:
       enabled: true



eureka:
  client:
    serviceUrl:
      defaultZone: http://{host}:{port}/eureka
    registerWithEureka: true
  instance:
    preferIpAddress: true  

hystrix:
  threadpool:
    default:
      coreSize: 1000
      maximumSize: 10000
       queueSizeRejectionThreshold: -1
     maxQueueSize: -1
  command:
    default:
      execution:
        isolation:
          strategy: THREAD
         thread:
              timeoutInMilliseconds: 60000

server:
  port: 9000


logging:
  file: /app/logs/aaa_gateway.log
  level:
    org.springframework.web: INFO
    com.customerhub.filters: INFO
    org.hibernate: INFO

customerhub:
  authorization:
    check-token-url: /oauth/check_token   

现在,在本地系统中的eclipse中执行时,它可以正常工作并从配置服务器中获取属性。

通过命令提示符运行相同的jar时,出现以下错误:

  

无法解析值“ $ {zuul.prefix}”中的占位符“ zuul.prefix”

日志文件为:

spring.profiles.active=dev
spring.application.name=gateway-server
spring.cloud.config.uri=http://{host}:{port}
management.security.enabled=false
management.endpoints.web.exposure.include=*

1 个答案:

答案 0 :(得分:0)

Spring无法找到if (SelectRoomActivity.bundle.getBoolean("local")){ serverAdress = address; //abc.ddns.net } else{ serverAdress = lan; //192.168.1.101 } 文件,因此请使用控制器顶部的以下代码在类路径中添加yml文件。

gateway-server-dev.yml

或通过将这些行添加到部分下的pom中

@PropertySource("classpath:gateway-server-dev.yml")

引用properties-with-spring