类 ServerPortInfoApplicationContextInitializer
- java.lang.Object
- org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer
- 所有已实现的接口:
EventListener
,org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
,org.springframework.context.ApplicationListener<WebServerInitializedEvent>
public class ServerPortInfoApplicationContextInitializer extends Object implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>, org.springframework.context.ApplicationListener<WebServerInitializedEvent>
ApplicationContextInitializer
that setsEnvironment
properties for the ports thatWebServer
servers are actually listening on. The property "local.server.port" can be injected directly into tests using@Value
or obtained via theEnvironment
.If the
WebServerInitializedEvent
has aserver namespace
, it will be used to construct the property name. For example, the "management" actuator context will have the property name "local.management.port".Properties are automatically propagated up to any parent context.
- 从以下版本开始:
- 2.0.0
构造器概要
构造器 构造器 说明 ServerPortInfoApplicationContextInitializer()
构造器详细资料
ServerPortInfoApplicationContextInitializer
public ServerPortInfoApplicationContextInitializer()
方法详细资料
initialize
public void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext)
- 指定者:
initialize
在接口中org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
onApplicationEvent
public void onApplicationEvent(WebServerInitializedEvent event)
- 指定者:
onApplicationEvent
在接口中org.springframework.context.ApplicationListener<WebServerInitializedEvent>