本文整理汇总了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);
}
}