Java Code Examples for org.springframework.boot.builder.SpringApplicationBuilder#properties()

The following examples show how to use org.springframework.boot.builder.SpringApplicationBuilder#properties() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlatformAuthServerApplication.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    SpringApplicationBuilder b = new SpringApplicationBuilder(PlatformAuthServerApplication.class);
    String loadDefaultProperties = System.getenv(ENV_KEY_LOAD_DEFAULT_PROPERTIES);

    if (loadDefaultProperties != null) {
        Properties loadedProperties = loadDefaultProperties();
        b.properties(loadedProperties);
        if (log.isInfoEnabled()) {
            StringBuilder sb = new StringBuilder();
            sb.append("loaded default properties:\n");
            
            loadedProperties.forEach( (k , v) -> {
                sb.append("key=").append(k).append(",value=").append(v).append("\n");
            });
            
            log.info(sb.toString());
        }
    }
    ConfigurableApplicationContext ctx = b.run(args);

    log.info("{} started for : {} ", PlatformAuthServerApplication.class.getSimpleName(),
            ctx.getEnvironment().getActiveProfiles());
}
 
Example 2
Source File: INCEpTION.java    From inception with Apache License 2.0 6 votes vote down vote up
private static void init(SpringApplicationBuilder aBuilder)
{
    // WebAnno relies on FS IDs being stable, so we need to enable this
    System.setProperty(CASImpl.ALWAYS_HOLD_ONTO_FSS, "true");
    
    aBuilder.banner(new InceptionBanner());
    aBuilder.initializers(new InceptionApplicationContextInitializer());
    aBuilder.headless(false);
    
    SettingsUtil.customizeApplication("inception.home", ".inception");
    
    // Traditionally, the INCEpTION configuration file is called settings.properties and is
    // either located in inception.home or under the user's home directory. Make sure we pick
    // it up from there in addition to reading the built-in application.properties file.
    aBuilder.properties("spring.config.additional-location="
            + "${inception.home:${user.home}/.inception}/settings.properties");
}
 
Example 3
Source File: INCEpTION.java    From inception with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception
{
    Optional<JWindow> splash = LoadingSplashScreen
            .setupScreen(INCEpTION.class.getResource("splash.png"));
    
    SpringApplicationBuilder builder = new SpringApplicationBuilder();
    // Add the main application as the root Spring context
    builder.sources(INCEpTION.class).web(SERVLET);
    
    // Signal that we may need the shutdown dialog
    builder.properties("running.from.commandline=true");
    init(builder);
    builder.listeners(event -> {
        if (event instanceof ApplicationReadyEvent
                || event instanceof ShutdownDialogAvailableEvent) {
            splash.ifPresent(it -> it.dispose());
        }
    });
    builder.run(args);
}
 
Example 4
Source File: WebAnno.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception
{
    Optional<JWindow> splash = LoadingSplashScreen
            .setupScreen(WebAnno.class.getResource("splash.png"));
    
    SpringApplicationBuilder builder = new SpringApplicationBuilder();
    // Add the main application as the root Spring context
    builder.sources(WebAnno.class).web(SERVLET);
    
    // Signal that we may need the shutdown dialog
    builder.properties("running.from.commandline=true");
    init(builder);
    builder.listeners(event -> {
        if (event instanceof ApplicationReadyEvent
                || event instanceof ShutdownDialogAvailableEvent) {
            splash.ifPresent(it -> it.dispose());
        }
    });
    builder.run(args);
}
 
Example 5
Source File: AbstractCfEnvTests.java    From java-cfenv with Apache License 2.0 5 votes vote down vote up
public Environment getEnvironment(Map<String, Object> properties) {
	SpringApplicationBuilder builder = new SpringApplicationBuilder(TestApp.class)
		.web(WebApplicationType.NONE);
	if (!CollectionUtils.isEmpty(properties)) {
		builder.properties(properties);
	}
	builder.bannerMode(Banner.Mode.OFF);
	ApplicationContext applicationContext = builder.run();
	Environment environment = applicationContext.getEnvironment();
	((ConfigurableApplicationContext) applicationContext).close();
	return environment;
}
 
Example 6
Source File: INCEpTION.java    From inception with Apache License 2.0 5 votes vote down vote up
@Override
protected SpringApplicationBuilder createSpringApplicationBuilder()
{
    SpringApplicationBuilder builder = super.createSpringApplicationBuilder();
    builder.properties("running.from.commandline=false");
    // add this property in the case of .war deployment
    builder.properties( 
            WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED 
            + "=false" );
    init(builder);
    return builder;
}
 
Example 7
Source File: LocalSkipperResource.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
@Override
protected void before() {

	final SpringApplicationBuilder builder = new SpringApplicationBuilder(LocalTestSkipperServer.class);

	builder.properties("spring.main.allow-bean-definition-overriding:true");

	if (this.configLocations  != null && this.configLocations.length > 0) {
		builder.properties(
			String.format("spring.config.additional-location:%s", StringUtils.arrayToCommaDelimitedString(this.configLocations))
		);
	}

	if (this.configNames  != null && this.configNames.length > 0) {
		builder.properties(
			String.format("spring.config.name:%s", StringUtils.arrayToCommaDelimitedString(this.configNames))
		);
	}

	this.app = builder.build();

	configurableApplicationContext = app.run(this.args);

	Collection<Filter> filters = configurableApplicationContext.getBeansOfType(Filter.class).values();
	mockMvc = MockMvcBuilders.webAppContextSetup((WebApplicationContext) configurableApplicationContext)
			.addFilters(filters.toArray(new Filter[filters.size()])).build();
	skipperPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}");
	LOGGER.info("Skipper Server is UP on port {}!", skipperPort);
}
 
Example 8
Source File: WebAnno.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
protected SpringApplicationBuilder createSpringApplicationBuilder()
{
    SpringApplicationBuilder builder = super.createSpringApplicationBuilder();
    builder.properties("running.from.commandline=false");
    init(builder);
    return builder;
}
 
Example 9
Source File: WebAnno.java    From webanno with Apache License 2.0 5 votes vote down vote up
private static void init(SpringApplicationBuilder aBuilder)
{
    // WebAnno relies on FS IDs being stable, so we need to enable this
    System.setProperty(CASImpl.ALWAYS_HOLD_ONTO_FSS, "true");
    
    aBuilder.banner(new WebAnnoBanner());
    aBuilder.initializers(new WebAnnoApplicationContextInitializer());
    aBuilder.headless(false);
    
    // Traditionally, the WebAnno configuration file is called settings.properties and is
    // either located in webanno.home or under the user's home directory. Make sure we pick
    // it up from there in addition to reading the built-in application.properties file.
    aBuilder.properties("spring.config.additional-location="
            + "${webanno.home:${user.home}/.webanno}/settings.properties");
}
 
Example 10
Source File: SyncopeEnduserApplication.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
protected SpringApplicationBuilder configure(final SpringApplicationBuilder builder) {
    builder.properties(WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED + "=false");
    return super.configure(builder);
}
 
Example 11
Source File: SyncopeConsoleApplication.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
protected SpringApplicationBuilder configure(final SpringApplicationBuilder builder) {
    builder.properties(WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED + "=false");
    return super.configure(builder);
}
 
Example 12
Source File: SofaArkEmbedUtils.java    From sofa-lookout with Apache License 2.0 3 votes vote down vote up
/**
 * enhance spring application builder with the ability to extract app related configs:
 * <ol>
 * <li>System Properties that start with "&lt;appName&gt;."</li>
 * <li>Environments that start with "&lt;appName&gt;."</li>
 * <li>Config Files Location which is specified by a system property "SOFA_ARK_CONFIGS" </li>
 * </ol>
 *
 * @param appName current app name
 * @param builder spring application builder
 */
public static void enhance(String appName, SpringApplicationBuilder builder) {
    Properties properties = parseSofaArkSupportProperties(appName);
    LOGGER.info("{} use properties {}", appName, properties);
    builder.properties(properties);
    builder.initializers(new SofaArkEmbedAppInitializer(appName));
}