You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc
+2-5Lines changed: 2 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -497,8 +497,8 @@ To scan for a free port (using OS natives to prevent clashes) use `server.port=0
497
497
498
498
[[howto-discover-the-http-port-at-runtime]]
499
499
=== Discover the HTTP Port at Runtime
500
-
You can access the port the server is running on from log output or from the `ServletWebServerApplicationContext` through its `WebServer`.
501
-
The best way to get that and be sure that it has been initialized is to add a `@Bean` of type `ApplicationListener<ServletWebServerInitializedEvent>` and pull the container out of the event when it is published.
500
+
You can access the port the server is running on from log output or from the `WebServerApplicationContext` through its `WebServer`.
501
+
The best way to get that and be sure it has been initialized is to add a `@Bean` of type `ApplicationListener<WebServerInitializedEvent>` and pull the container out of the event when it is published.
502
502
503
503
Tests that use `@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)` can also inject the actual port into a field by using the `@LocalServerPort` annotation, as shown in the following example:
504
504
@@ -507,9 +507,6 @@ Tests that use `@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)` can
0 commit comments