我正在尝试在运行时向 tomcat 添加一个端口。有没有办法做到这一点?或者有没有办法监听所有端口?我正在使用 spring,我希望用户能够添加调用 API 端点以添加新的端口来监听。
我知道您可以在配置文件中添加其他端口,但我不知道需要添加哪些端口。
@RequestMapping("/port/{port}")
void setPort(@PathVariable("port") int port){
//add new tomcat port to listen on
}
最佳答案
@Component public class CustomizationBean implements WebServerFactoryCustomizer { @Override public void customize(ConfigurableServletWebServerFactory container) { container.setPort(8083); } }
关于java - 有没有办法在运行时向tomcat添加端口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56367569/