试试这个我觉得这有助于你解决问题..
这是我的网关bootstrap.yml文件
spring:
application:
name: gateway-service
spring:
profiles: default
cloud:
consul:
config:
prefix: config/dev/
format: FILES
host: localhost
port: 8500
discovery:
prefer-ip-address: true
spring.profiles.active: dev
</code>
我将此依赖关系用于网关和所有应用程序
org.springframework.cloud
spring-cloud-starter-consul-discovery
org.springframework.cloud
spring-cloud-starter-consul-config
</code>
consul用作我的配置服务器。然后我添加consul这个配置。配置路径是/config/dev/gateway.yml
zuul:
prefix: /api
ignoredServices: ‘*’
host:
connect-timeout-millis: 20000
socket-timeout-millis: 20000
routes:
customer-service:
path: /customer/**
serviceId: customer-service
stripPrefix: false
sensitiveHeaders: Cookie,Set-Cookie
</code>
网关服务spring boot应用程序注释如下
@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
public class GatewayServiceApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayServiceApplication.class, args);
} // End main ()
}// End GatewayServiceApplication
</code>
如果你像这样制作你的应用程序,你可以使用你更喜欢的路径。