Example usage for org.springframework.boot.context.config ConfigFileApplicationListener ConfigFileApplicationListener

List of usage examples for org.springframework.boot.context.config ConfigFileApplicationListener ConfigFileApplicationListener

Introduction

In this page you can find the example usage for org.springframework.boot.context.config ConfigFileApplicationListener ConfigFileApplicationListener.

Prototype

ConfigFileApplicationListener

Source Link

Usage

From source file:org.obiba.rserver.Application.java

public static void main(String... args) throws Exception {
    ConfigFileApplicationListener listener = new ConfigFileApplicationListener();
    listener.setSearchLocations("classpath:,file:" + Resources.getRServerHomeDir() + "/conf/");

    SpringApplication springApp = new SpringApplication(Application.class);
    springApp.addListeners(listener);//from  w  ww  .  j ava2s  .c  om
    springApp.run(args);
}

From source file:org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.java

@Override
public Environment findOne(String config, String profile, String label) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(PropertyPlaceholderAutoConfiguration.class);
    ConfigurableEnvironment environment = getEnvironment(profile);
    builder.environment(environment);//from w  w  w. j av a2 s  . co  m
    builder.web(false).bannerMode(Mode.OFF);
    if (!logger.isDebugEnabled()) {
        // Make the mini-application startup less verbose
        builder.logStartupInfo(false);
    }
    String[] args = getArgs(config, profile, label);
    // Explicitly set the listeners (to exclude logging listener which would change
    // log levels in the caller)
    builder.application().setListeners(Arrays.asList(new ConfigFileApplicationListener()));
    ConfigurableApplicationContext context = builder.run(args);
    environment.getPropertySources().remove("profiles");
    try {
        return clean(new PassthruEnvironmentRepository(environment).findOne(config, profile, label));
    } finally {
        context.close();
    }
}

From source file:org.springframework.cloud.config.server.NativeEnvironmentRepository.java

@Override
public Environment findOne(String config, String profile, String label) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(PropertyPlaceholderAutoConfiguration.class);
    ConfigurableEnvironment environment = getEnvironment(profile);
    builder.environment(environment);//from  w w  w. j  a  v  a  2  s  .  com
    builder.web(false).showBanner(false);
    String[] args = getArgs(config, label);
    // Explicitly set the listeners (to exclude logging listener which would change
    // log levels in the caller)
    builder.application().setListeners(Collections.singletonList(new ConfigFileApplicationListener()));
    ConfigurableApplicationContext context = builder.run(args);
    environment.getPropertySources().remove("profiles");
    try {
        return clean(new PassthruEnvironmentRepository(environment).findOne(config, profile, label));
    } finally {
        context.close();
    }
}