Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 无法解析占位符';zuul.前缀';“在价值上”${zuul.prefix}”;_Spring Boot_Netflix Zuul_Spring Cloud Config - Fatal编程技术网

Spring boot 无法解析占位符';zuul.前缀';“在价值上”${zuul.prefix}”;

Spring boot 无法解析占位符';zuul.前缀';“在价值上”${zuul.prefix}”;,spring-boot,netflix-zuul,spring-cloud-config,Spring Boot,Netflix Zuul,Spring Cloud Config,我有一个与网关服务器(Zuul)的微服务项目,与配置服务器集成的eureka服务器 我有一个git存储库,其中包含网关服务器的属性文件(gateway-server-dev.yml) gateway-server-dev.yml文件: spring: application: name: gateway-server info: component: Gateway Server endpoints: restart: enabled: true sh

我有一个与网关服务器(Zuul)的微服务项目,与配置服务器集成的eureka服务器

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

gateway-server-dev.yml文件:

    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   
网关服务器中的引导文件为:

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=*
现在,当我在本地系统的eclipse中执行时,它工作正常,并从配置服务器获取属性

当我通过命令提示符运行同一个jar时,会出现以下错误:

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

日志文件为:

2018-11-16 15:08:01.523  INFO 8604 --- [ost-startStop-1] 
c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic 
configuration sources, define System property 
archaius.configurationSource.additionalUrls or make config.properties 
available on classpath.
2018-11-16 15:08:01.555  INFO 8604 --- [ost-startStop-1] 
c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is 
initialized with configuration sources: 
com.netflix.config.ConcurrentCompositeConfiguration@ef4443e
2018-11-16 15:08:01.977 ERROR 8604 --- [ost-startStop-1] 
o.s.b.c.embedded.tomcat.TomcatStarter    : Error starting Tomcat context. 
Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. 
Message: Error creating bean with name'org.springframework.cloud.netflix.zuul.ZuulConfiguration$ZuulFilterConfigur 
  ation': Unsatisfied dependency expressed through field 'filters'; nested 
exception is org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'preFilter': Injection of autowired dependencies 
failed; nested exception is java.lang.IllegalArgumentException: Could not 
resolve placeholder 'zuul.prefix' in value "${zuul.prefix}"

Spring无法找到
gateway-server-dev.yml
文件,因此在控制器顶部使用下面的代码将yml文件添加到类路径中

@PropertySource("classpath:gateway-server-dev.yml")
或者将这些行添加到该节下的pom中

<resource>
     <directory>src/main/resources</directory>
     <filtering>true</filtering>
     <includes>
          <include>**/*.yml</include>
     </includes>
</resource>

src/main/resources
符合事实的
**/*yml先生

请参阅我的.yml文件位于git存储库中。它给出以下错误:原因:java.io.FileNotFoundException:无法打开类路径资源[gateway-server-dev.yml],因为它不存在