在两个端口中启动 Spring 引导 REST 控制器
Starting Spring boot REST controller in two ports
有没有办法在一个 spring 启动应用程序的两个不同端口上安装两个休息控制器 运行?
例如在一个 SpringBoot 主应用程序中 http://localhost:8080 and Controller_B running in http://localhost:9090 Controller_A 运行 ?
执行此操作的一种方法实际上是创建两个应用程序属性;
app-A.properties
server.port=8080
app-B.properties
server.port=9090
然后在你的控制器中,像下面这样添加注释;
@Profile("A")
public class ControllerA {
...
}
@Profile("B")
public class ControllerB {
...
}
最后您需要使用以下设置启动您的应用程序两次;
java -jar -Dspring.profiles.active=A awesomeSpringApp.jar
java -jar -Dspring.profiles.active=B awesomeSpringApp.jar
有没有办法在一个 spring 启动应用程序的两个不同端口上安装两个休息控制器 运行?
例如在一个 SpringBoot 主应用程序中 http://localhost:8080 and Controller_B running in http://localhost:9090 Controller_A 运行 ?
执行此操作的一种方法实际上是创建两个应用程序属性;
app-A.properties
server.port=8080
app-B.properties
server.port=9090
然后在你的控制器中,像下面这样添加注释;
@Profile("A")
public class ControllerA {
...
}
@Profile("B")
public class ControllerB {
...
}
最后您需要使用以下设置启动您的应用程序两次;
java -jar -Dspring.profiles.active=A awesomeSpringApp.jar
java -jar -Dspring.profiles.active=B awesomeSpringApp.jar