[英]How to run api-gateway(Netflix Zuul) and Eureka Server on different port in one Spring Boot application
I have a Spring Boot
application which is EurekaServer
as well as ZuulServer
.我有一个
Spring Boot
应用程序,它是EurekaServer
和ZuulServer
。 My questions are:我的问题是:
I have attached the configuration which I tried, but it's not giving me the desired output.我附上了我尝试过的配置,但它没有给我想要的输出。
@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/
You can try like below您可以尝试如下
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
The best way to design microservice is to have separate EurekaServer and register your ZuulServer to Eureka.设计微服务的最佳方式是拥有单独的 EurekaServer,并将您的 ZuulServer 注册到 Eureka。 Please refer below link
请参考以下链接
https://tech.asimio.net/2016/12/15/Configuring-Tomcat-to-Listen-on-Multiple-ports-using-Spring-Boot.html https://tech.asimio.net/2016/12/15/Configuring-Tomcat-to-Listen-on-Multiple-ports-using-Spring-Boot.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.