当前位置: 首页>>代码示例>>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;未经允许,请勿转载。