本文整理匯總了Java中org.springframework.context.ApplicationContext.getEnvironment方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationContext.getEnvironment方法的具體用法?Java ApplicationContext.getEnvironment怎麽用?Java ApplicationContext.getEnvironment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.ApplicationContext
的用法示例。
在下文中一共展示了ApplicationContext.getEnvironment方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws Exception {
SpringApplication app = new SpringApplication(AlbedoThriftExampleServer.class);
final ApplicationContext applicationContext = app.run(args);
Environment env = applicationContext.getEnvironment();
log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! ",
env.getProperty("spring.application.name"));
}
示例2: setParent
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
/**
* {@inheritDoc}
* <p>The parent {@linkplain ApplicationContext#getEnvironment() environment} is
* {@linkplain ConfigurableEnvironment#merge(ConfigurableEnvironment) merged} with
* this (child) application context environment if the parent is non-{@code null} and
* its environment is an instance of {@link ConfigurableEnvironment}.
* @see ConfigurableEnvironment#merge(ConfigurableEnvironment)
*/
@Override
public void setParent(ApplicationContext parent) {
this.parent = parent;
if (parent != null) {
Environment parentEnvironment = parent.getEnvironment();
if (parentEnvironment instanceof ConfigurableEnvironment) {
getEnvironment().merge((ConfigurableEnvironment) parentEnvironment);
}
}
}
示例3: build
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public DefaultSuiteIdentifier build(ApplicationContext context) {
setHostInformation();
Environment environment = context.getEnvironment();
return new DefaultSuiteIdentifier(UUID.randomUUID(),
context.getStartupDate(),
context.getDisplayName(),
hostname,
address,
System.getProperty("user.name"),
ImmutableSet.copyOf(environment.getActiveProfiles()),
ImmutableMap.copyOf(System.getenv()));
}
示例4: main
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(String[] args) throws Exception {
SpringApplication app = new SpringApplication(AlbedoThriftExampleClient.class);
final ApplicationContext applicationContext = app.run(args);
Environment env = applicationContext.getEnvironment();
log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! ",
env.getProperty("spring.application.name"));
}
示例5: init
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
protected void init(ApplicationContext applicationContext) {
Environment env = applicationContext.getEnvironment();
if (isCloudConsulEnabled(env) || isCloudEurekaEnabled(env) || isCloudZookeeperEnabled(env)) {
cloudyDiscoveryEnabled.compareAndSet(false, true);
}
}