本文整理汇总了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();
};
}
示例2: applicationRunner
import org.springframework.boot.ApplicationRunner; //导入依赖的package包/类
@Bean
public ApplicationRunner applicationRunner() {
return new JmxCollector( collectorMetrics(), configFile, taskScheduler(), taskExecutor(), pollRateMs, jmxConnectionStateResolver(), statsdClient(), objectMapper() );
}
示例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");
};
}
示例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();
}
示例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));
};
}
示例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);
}
示例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();
};
}
示例9: helpAwareShellApplicationRunner
import org.springframework.boot.ApplicationRunner; //导入依赖的package包/类
@Bean
public ApplicationRunner helpAwareShellApplicationRunner() {
return new HelpAwareShellApplicationRunner();
}
示例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);
}
示例11: applicationRunner
import org.springframework.boot.ApplicationRunner; //导入依赖的package包/类
@Bean
public ApplicationRunner applicationRunner(Shell shell, ConfigurableEnvironment environment) {
return new InteractiveModeApplicationRunner(shell, environment);
}
示例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")));
}
示例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());
});
}