@EventListener(WebServerInitializedEvent.class) public void bind(WebServerInitializedEvent event) { ApplicationContext context = event.getApplicationContext(); if (context instanceof ServletWebServerApplicationContext) { if ("management".equals( ((ServletWebServerApplicationContext) context).getNamespace())) { return; } } this.port.compareAndSet(0, event.getWebServer().getPort()); this.start(); }
@EventListener public void onWebServerInitialized(WebServerInitializedEvent event) { if ("server".equals(event.getServerId())) { localServerPort = event.getWebServer().getPort(); } if ("management".equals(event.getServerId())) { localManagementPort = event.getWebServer().getPort(); } }
@Override public void onApplicationEvent(WebServerInitializedEvent event) { this.port = event.getWebServer().getPort(); }