當前位置: 首頁>>代碼示例>>Java>>正文


Java SpringApplicationBuilder類代碼示例

本文整理匯總了Java中org.springframework.boot.builder.SpringApplicationBuilder的典型用法代碼示例。如果您正苦於以下問題:Java SpringApplicationBuilder類的具體用法?Java SpringApplicationBuilder怎麽用?Java SpringApplicationBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SpringApplicationBuilder類屬於org.springframework.boot.builder包,在下文中一共展示了SpringApplicationBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    /**
     * set a default to use when no profile is configured.
     */
    DefaultProfileUtil.addDefaultProfile(application.application());
    return application.sources(StoreApp.class);
}
 
開發者ID:deepu105,項目名稱:spring-io,代碼行數:9,代碼來源:ApplicationWebXml.java

示例2: main

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    ConfigurableApplicationContext context = builder.run(args);
    LOGGER.info("collector backup start successfully");

    KafkaConsumer kafkaConsumer = (KafkaConsumer<byte[], String>) context.getBean("kafkaConsumer");
    Task task = (Task) context.getBean("backupTask");

    // 優雅停止項目
    Runtime.getRuntime().addShutdownHook(new ShutdownHookRunner(kafkaConsumer, task));
    task.doTask();
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:21,代碼來源:Launcher.java

示例3: main

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
  // below is output *before* logging is configured so will appear on console
  logVersionInfo();

  try {
    SpringApplication.exit(new SpringApplicationBuilder(ComparisonTool.class)
        .properties("spring.config.location:${config:null}")
        .properties("spring.profiles.active:" + Modules.REPLICATION)
        .properties("instance.home:${user.home}")
        .properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
        .bannerMode(Mode.OFF)
        .registerShutdownHook(true)
        .build()
        .run(args));
  } catch (BeanCreationException e) {
    if (e.getMostSpecificCause() instanceof BindException) {
      printComparisonToolHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
      throw e;
    }
    if (e.getMostSpecificCause() instanceof IllegalArgumentException) {
      LOG.error(e.getMessage(), e);
      printComparisonToolHelp(Collections.<ObjectError> emptyList());
    }
  }
}
 
開發者ID:HotelsDotCom,項目名稱:circus-train,代碼行數:26,代碼來源:ComparisonTool.java

示例4: useRemoteTokenServices

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Test
public void useRemoteTokenServices() {
	TestPropertyValues.of("security.oauth2.resource.tokenInfoUri:http://example.com")
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
			.environment(this.environment).web(WebApplicationType.NONE).run();
	RemoteTokenServices services = this.context.getBean(RemoteTokenServices.class);
	assertThat(services).isNotNull();
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:10,代碼來源:ResourceServerTokenServicesConfigurationTests.java

示例5: switchToUserInfo

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Test
public void switchToUserInfo() {
	TestPropertyValues.of("security.oauth2.resource.userInfoUri:http://example.com")
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(ResourceConfiguration.class)
			.environment(this.environment).web(WebApplicationType.NONE).run();
	UserInfoTokenServices services = this.context
			.getBean(UserInfoTokenServices.class);
	assertThat(services).isNotNull();
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:11,代碼來源:ResourceServerTokenServicesConfigurationTests.java

示例6: userInfoWithAuthorities

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Test
public void userInfoWithAuthorities() {
	TestPropertyValues.of("security.oauth2.resource.userInfoUri:http://example.com")
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(AuthoritiesConfiguration.class)
			.environment(this.environment).web(WebApplicationType.NONE).run();
	UserInfoTokenServices services = this.context
			.getBean(UserInfoTokenServices.class);
	assertThat(services).isNotNull();
	assertThat(services).extracting("authoritiesExtractor")
			.containsExactly(this.context.getBean(AuthoritiesExtractor.class));
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:13,代碼來源:ResourceServerTokenServicesConfigurationTests.java

示例7: configure

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    /**
     * set a default to use when no profile is configured.
     */
    DefaultProfileUtil.addDefaultProfile(application.application());
    return application.sources(EntityApp.class);
}
 
開發者ID:xm-online,項目名稱:xm-ms-entity,代碼行數:9,代碼來源:ApplicationWebXml.java

示例8: configure

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    /**
     * set a default to use when no profile is configured.
     */
    DefaultProfileUtil.addDefaultProfile(application.application());
    return application.sources(BalanceApp.class);
}
 
開發者ID:xm-online,項目名稱:xm-ms-balance,代碼行數:9,代碼來源:ApplicationWebXml.java

示例9: SpringCloudFunctionInvoker

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
/**
 * A common pattern is to call this function from within a Configuration method of
 * a {@link org.springframework.beans.factory.annotation.Configurable} function.
 *
 * @param configClass The class which defines your Spring Cloud Function @Beans
 */
public SpringCloudFunctionInvoker(Class<?> configClass) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(configClass);
    applicationContext = builder.web(false).run();
    loader = applicationContext.getAutowireCapableBeanFactory().createBean(SpringCloudFunctionLoader.class);
    loader.loadFunction();
}
 
開發者ID:fnproject,項目名稱:fdk-java,代碼行數:13,代碼來源:SpringCloudFunctionInvoker.java

示例10: jwkTokenStoreShouldBeConditionalOnMissingBean

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Test
public void jwkTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
	TestPropertyValues
			.of("security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys")
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class,
			ResourceConfiguration.class).environment(this.environment)
					.web(WebApplicationType.NONE).run();
	assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:11,代碼來源:ResourceServerTokenServicesConfigurationTests.java

示例11: jwtTokenStoreShouldBeConditionalOnMissingBean

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Test
public void jwtTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
	TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY)
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class,
			ResourceConfiguration.class).environment(this.environment)
					.web(WebApplicationType.NONE).run();
	assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:10,代碼來源:ResourceServerTokenServicesConfigurationTests.java

示例12: configure

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    /**
     * set a default to use when no profile is configured.
     */
    DefaultProfileUtil.addDefaultProfile(application.application());
    return application.sources(LabratApp.class);
}
 
開發者ID:Microsoft,項目名稱:MTC_Labrat,代碼行數:9,代碼來源:ApplicationWebXml.java

示例13: main

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
public static void main(String[] args) {
  	SpringApplication springApplication = new SpringApplicationBuilder()
		.sources(BittrexGathererApplication.class)
		.web(false)
		.build();
	
springApplication.run();
      
  }
 
開發者ID:AlxGDev,項目名稱:BittrexGatherer,代碼行數:10,代碼來源:BittrexGathererApplication.java

示例14: main

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("接口A start successfully");
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:15,代碼來源:Application.java

示例15: main

import org.springframework.boot.builder.SpringApplicationBuilder; //導入依賴的package包/類
public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(Launcher.class);
    Set<ApplicationListener<?>> listeners = builder.application().getListeners();
    for (Iterator<ApplicationListener<?>> it = listeners.iterator(); it.hasNext();) {
        ApplicationListener<?> listener = it.next();
        if (listener instanceof LoggingApplicationListener) {
            it.remove();
        }
    }
    builder.application().setListeners(listeners);
    builder.run(args);

    LOGGER.info("服務C start successfully");

    // 優雅停止項目
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            LOGGER.info("try to stop the system");
            synchronized (Launcher.class) {
                RUNNING = false;
                Launcher.class.notify();
            }
        }
    });

    synchronized (Launcher.class) {
        while (RUNNING) {
            try {
                Launcher.class.wait();
            } catch (InterruptedException e) {
                LOGGER.error("wait error");
                e.printStackTrace();
            }
        }
    }
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:38,代碼來源:Launcher.java


注:本文中的org.springframework.boot.builder.SpringApplicationBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。