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


Java ApplicationRunner類代碼示例

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


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

示例1: onStart

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
/**
 * Application runner to initialize a capped collection for {@link Event}s and insert a new {@link Event} every two
 * seconds.
 * 
 * @param operations
 * @param reactiveOperations
 * @return
 */
@Bean
ApplicationRunner onStart(MongoOperations operations, ReactiveMongoOperations reactiveOperations) {

	return args -> {

		CollectionOptions options = CollectionOptions.empty() //
				.capped() //
				.size(2048) //
				.maxDocuments(1000);

		operations.dropCollection(Event.class);
		operations.createCollection(Event.class, options);

		Flux.interval(Duration.ofSeconds(2)) //
				.map(counter -> new Event(LocalDateTime.now())) //
				.flatMap(reactiveOperations::save) //
				.log() //
				.subscribe();
	};
}
 
開發者ID:olivergierke,項目名稱:spring-five-functional-reactive,代碼行數:29,代碼來源:WebfluxDemo.java

示例2: applicationRunner

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
public ApplicationRunner applicationRunner() {
    return new JmxCollector( collectorMetrics(), configFile, taskScheduler(), taskExecutor(), pollRateMs, jmxConnectionStateResolver(), statsdClient(), objectMapper() );
}
 
開發者ID:cslee00,項目名稱:datadog-jmx-collector,代碼行數:5,代碼來源:JmxCollectorMain.java

示例3: run

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
ApplicationRunner run() {
    return args -> {
        log.debug("run");
        ListenableFuture<String> s = myService.hello();
        s.addCallback(a -> log.debug(a), e -> log.debug(e.getMessage()));
        log.debug("exit");
    };

}
 
開發者ID:sejoung,項目名稱:ReactiveTest,代碼行數:11,代碼來源:Spring5Application.java

示例4: applicationRunner

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
ApplicationRunner applicationRunner(CustomerRepository customerRepository) {
    return args -> {

        Stream.of("a", "b", "c")
                .forEach(n -> customerRepository.save(new Customer(null, n, n,
                n + "@" + n + ".com")));
    };
}
 
開發者ID:applied-continuous-delivery-livelessons,項目名稱:testing-101,代碼行數:10,代碼來源:CustomerServiceApplication.java

示例5: onStartup

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
/**
 * Initializes the repository with a sample user.
 * 
 * @param repository the repository to create {@link User}s in.
 * @return
 */
@Bean
ApplicationRunner onStartup(UserRepository repository) {

	// We need to call ….block() here to actually execute the call.
	return (args) -> repository.save(new User("Dave Matthews")).block();
}
 
開發者ID:olivergierke,項目名稱:spring-five-functional-reactive,代碼行數:13,代碼來源:WebfluxFnConfiguration.java

示例6: init

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
ApplicationRunner init(BookRepository repository) {
    // init db
    return args -> {
        repository.save(new Book("Java tutorial", 1995));
        repository.save(new Book("Spring reference", 2016));
    };
}
 
開發者ID:verydapeng,項目名稱:boot-works,代碼行數:9,代碼來源:BootApplication.java

示例7: initUsers

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
ApplicationRunner initUsers(PasswordEncoder encoder, AccountRepository repository) {
    // init db, for demo
    return args -> Stream.of(
            new Account("user", encoder.encode("password"), "USER"),
            new Account("admin", encoder.encode("password"), "USER,ROLE_ADMIN")).forEach(repository::save);
}
 
開發者ID:verydapeng,項目名稱:boot-works,代碼行數:8,代碼來源:BootApplication.java

示例8: initialize

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
public ApplicationRunner initialize(final ReactiveMongoTemplate mongoTemplate) {
	return args -> {

		/*
		 * INSERT ALL THE NEEDED TEST DATA (will block)
		 */
		Data.initializeAllData(mongoTemplate);

		/*
		 * INITIALIZATION OF THE MATCH EVENT STREAM
		 */
		final MatchEventAgent matchEventAgent = new MatchEventAgent(mongoTemplate);
		final Flux<MatchEvent> matchEventStream = matchEventAgent.createAgentStream();
		// Subscribe and just let it run (forever)
		matchEventStream.subscribe();

		/*
		 * INITIALIZATION OF THE MATCH COMMENT STREAM
		 */
		final MatchCommentAgent matchCommentAgent = new MatchCommentAgent(mongoTemplate);
		final Flux<MatchComment> matchCommentStream = matchCommentAgent.createAgentStream();
		// Subscribe and just let it run (forever)
		matchCommentStream.subscribe();

	};
}
 
開發者ID:danielfernandez,項目名稱:reactive-matchday,代碼行數:28,代碼來源:MatchDayWebApplication.java

示例9: helpAwareShellApplicationRunner

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
public ApplicationRunner helpAwareShellApplicationRunner() {
	return new HelpAwareShellApplicationRunner();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:5,代碼來源:ShellConfiguration.java

示例10: initializeConnectionApplicationRunner

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
public ApplicationRunner initializeConnectionApplicationRunner(TargetHolder targetHolder,
															@Qualifier("main") ResultHandler<Exception> resultHandler,
															SkipperClientProperties skipperClientProperties) {
	return new InitializeConnectionApplicationRunner(targetHolder, resultHandler, skipperClientProperties);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:7,代碼來源:ShellConfiguration.java

示例11: applicationRunner

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
public ApplicationRunner applicationRunner(Shell shell, ConfigurableEnvironment environment) {
	return new InteractiveModeApplicationRunner(shell, environment);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:5,代碼來源:ShellConfiguration.java

示例12: init

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
ApplicationRunner init(CustomerRepository repository) {
    return args ->
            Stream.of("a", "b", "c")
                    .forEach(n -> repository.save(new Customer(n, n, n + "@" + n + ".com")));
}
 
開發者ID:applied-continuous-delivery-livelessons,項目名稱:cdct,代碼行數:7,代碼來源:CustomerServiceApplication.java

示例13: runner

import org.springframework.boot.ApplicationRunner; //導入依賴的package包/類
@Bean
public ApplicationRunner runner(PollableMessageSource pollableSource) {
	return args -> pollableSource.poll(message -> {
		System.out.println("Polled payload: " + message.getPayload());
	});
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream,代碼行數:7,代碼來源:SampleStreamApp.java


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