类 ServerPortInfoApplicationContextInitializer
- java.lang.Object
- org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer
- 所有已实现的接口:
org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
public class ServerPortInfoApplicationContextInitializer extends Object implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
ApplicationContextInitializerthat setsEnvironmentproperties for the ports thatEmbeddedServletContainerservers are actually listening on. The property "local.server.port" can be injected directly into tests using@Valueor obtained via theEnvironment.If the
EmbeddedWebApplicationContexthas anamespaceset, 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.
- 从以下版本开始:
- 1.4.0
构造器概要
构造器 构造器 说明 ServerPortInfoApplicationContextInitializer()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected StringgetPropertyName(EmbeddedWebApplicationContext context)voidinitialize(org.springframework.context.ConfigurableApplicationContext applicationContext)protected voidonApplicationEvent(EmbeddedServletContainerInitializedEvent event)
构造器详细资料
ServerPortInfoApplicationContextInitializer
public ServerPortInfoApplicationContextInitializer()
方法详细资料
initialize
public void initialize(org.springframework.context.ConfigurableApplicationContext applicationContext)
- 指定者:
initialize在接口中org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
onApplicationEvent
protected void onApplicationEvent(EmbeddedServletContainerInitializedEvent event)
getPropertyName
protected String getPropertyName(EmbeddedWebApplicationContext context)