Search in sources :

Example 86 with SpringApplication

use of org.springframework.boot.SpringApplication in project kylo by Teradata.

the class KyloServerApplication method main.

public static void main(String[] args) {
    // Configure java.util.logging for Kylo Spark Shell
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    // Run upgrader
    KyloUpgrader upgrader = new KyloUpgrader();
    if (upgrader.isUpgradeRequired()) {
        try {
            KyloVersion currentVersion = upgrader.getCurrentVersion();
            log.info("*****  Upgrade required - this may take some time  *****");
            log.info("Beginning upgrade from version {} ...", currentVersion == null ? "unknown" : currentVersion);
            upgrader.upgrade();
            log.info("*****  Upgrading complete  *****");
        } catch (Exception e) {
            log.error("Error during upgrade: {}", e.getMessage());
            log.error("*****  Upgrading failed  *****");
            System.exit(1);
        }
    } else {
        log.info("Kylo v{} is up to date.  Starting the application.", KyloVersionUtil.getBuildVersion());
    }
    // Run services
    System.setProperty(SpringApplication.BANNER_LOCATION_PROPERTY, "banner.txt");
    SpringApplication application = new SpringApplication("classpath:application-context.xml");
    application.addInitializers(ctx -> validateMinProfiles(ctx));
    application.run(args);
}
Also used : KyloVersion(com.thinkbiganalytics.KyloVersion) SpringApplication(org.springframework.boot.SpringApplication) KyloUpgrader(com.thinkbiganalytics.server.upgrade.KyloUpgrader) KyloProfileException(com.thinkbiganalytics.rest.exception.profiles.KyloProfileException)

Example 87 with SpringApplication

use of org.springframework.boot.SpringApplication in project alf.io by alfio-event.

the class SpringBootLauncher method main.

/**
 * Entry point for spring boot
 * @param args original arguments
 */
public static void main(String[] args) {
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
    String profiles = System.getProperty("spring.profiles.active", "");
    SpringApplication application = new SpringApplication(SpringBootInitializer.class, BaseConfiguration.class, DataSourceConfiguration.class, WebSecurityConfig.class, MvcConfiguration.class);
    List<String> additionalProfiles = new ArrayList<>();
    additionalProfiles.add(Initializer.PROFILE_SPRING_BOOT);
    if ("true".equals(System.getenv("ALFIO_LOG_STDOUT_ONLY"))) {
        // -> will load application-stdout.properties on top to override the logger configuration
        additionalProfiles.add("stdout");
    }
    if ("true".equals(System.getenv("ALFIO_DEMO_ENABLED"))) {
        additionalProfiles.add(Initializer.PROFILE_DEMO);
    }
    application.setAdditionalProfiles(additionalProfiles.toArray(new String[0]));
    ConfigurableApplicationContext applicationContext = application.run(args);
    ConfigurableEnvironment environment = applicationContext.getEnvironment();
    log.info("profiles: requested {}, active {}", profiles, String.join(", ", environment.getActiveProfiles()));
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) SpringApplication(org.springframework.boot.SpringApplication) ArrayList(java.util.ArrayList) DefaultExceptionHandler(alfio.util.DefaultExceptionHandler)

Example 88 with SpringApplication

use of org.springframework.boot.SpringApplication in project sofa-ark by alipay.

the class SpringBoot2IntrospectBizEndpointOnArkDisabledTest method testIntrospectBizEndpoint.

@Test
public void testIntrospectBizEndpoint() {
    SpringApplication springApplication = new SpringApplication(EmptyConfiguration.class);
    ConfigurableApplicationContext applicationContext = springApplication.run(new String[] {});
    Assert.assertFalse(applicationContext.containsBean("introspectBizEndpoint"));
    applicationContext.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringApplication(org.springframework.boot.SpringApplication) Test(org.junit.Test)

Example 89 with SpringApplication

use of org.springframework.boot.SpringApplication in project sofa-ark by alipay.

the class SpringBoot2IntrospectBizEndpointOnArkEnabledTest method testDisableBizStateEndpoint.

@Test
public void testDisableBizStateEndpoint() {
    Map<String, Object> properties = new HashMap<>();
    properties.put("management.endpoint.bizState.enabled", "false");
    SpringApplication springApplication = new SpringApplication(EmptyConfiguration.class);
    springApplication.setDefaultProperties(properties);
    ConfigurableApplicationContext applicationContext = springApplication.run(new String[] {});
    Assert.assertFalse(applicationContext.containsBean("introspectBizEndpoint"));
    applicationContext.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) HashMap(java.util.HashMap) SpringApplication(org.springframework.boot.SpringApplication) Test(org.junit.Test)

Example 90 with SpringApplication

use of org.springframework.boot.SpringApplication in project sofa-ark by alipay.

the class BaseSpringApplication method main.

public static void main(String[] args) {
    SpringApplication springApplication = new SpringApplication(BaseSpringApplication.class);
    springApplication.run(args);
}
Also used : SpringApplication(org.springframework.boot.SpringApplication)

Aggregations

SpringApplication (org.springframework.boot.SpringApplication)205 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)56 Test (org.junit.Test)43 Test (org.junit.jupiter.api.Test)39 Environment (org.springframework.core.env.Environment)21 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)15 HashMap (java.util.HashMap)9 ApplicationFailedEvent (org.springframework.boot.context.event.ApplicationFailedEvent)9 ApplicationReadyEvent (org.springframework.boot.context.event.ApplicationReadyEvent)9 ApplicationStartingEvent (org.springframework.boot.context.event.ApplicationStartingEvent)9 File (java.io.File)7 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 JavaLoggingSystem (org.springframework.boot.logging.java.JavaLoggingSystem)6 ApplicationContext (org.springframework.context.ApplicationContext)6 ApplicationPreparedEvent (org.springframework.boot.context.event.ApplicationPreparedEvent)5 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)4 JoranException (ch.qos.logback.core.joran.spi.JoranException)3 IOException (java.io.IOException)3