我有一个Spring Boot
应用程序,它同时是EurekaServer
和ZuulServer
。我的问题是:
我已经附上了我尝试过的配置,但是没有给我想要的输出。
@SpringBootApplication
@EnableZuulProxy
@EnableEurekaServer
public class AppApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(AppApiGatewayApplication.class, args);
}
}
spring:
application:
name: gateway
server:
port: 8001
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:9090/eureka/
您可以尝试以下操作
server:
port: ${appPort:8880}
additionalPorts: 8882,8883
# Spring MVC actuator endpoints available via /admin/info, /admin/health, ...
server.servlet-path: /
management:
context-path: /admin
port: 8881
设计微服务的最佳方法是拥有单独的EurekaServer并将您的ZuulServer注册到Eureka。请参考下面的链接