Skip to content

Commit f61a4f8

Browse files
authored
Update WebfluxDemoApplication.java
1 parent 37337b0 commit f61a4f8

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/main/java/com/example/webfluxdemo/WebfluxDemoApplication.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
11
package com.example.webfluxdemo;
22

3+
import java.util.Date;
4+
import java.util.UUID;
5+
import java.util.stream.Stream;
6+
7+
import org.springframework.boot.CommandLineRunner;
38
import org.springframework.boot.SpringApplication;
49
import org.springframework.boot.autoconfigure.SpringBootApplication;
10+
import org.springframework.context.annotation.Bean;
11+
12+
import com.example.webfluxdemo.model.Employee;
13+
import com.example.webfluxdemo.repository.EmployeeRepository;
514

615
/**
7-
* @author : Bhawani Singh Shekhawat
16+
* @author : Bhawani Singh Shekhawat
817
* @date : 06-July-2019
918
*/
1019
@SpringBootApplication
1120
public class WebfluxDemoApplication {
1221

22+
@Bean
23+
CommandLineRunner employees(EmployeeRepository employeeRepository) {
24+
25+
return args -> {
26+
employeeRepository.deleteAll().subscribe(null, null, () -> {
27+
Stream.of(new Employee("Peter", "Create Employee"), new Employee("Sam", "Create Employee"),
28+
new Employee("Ryan", "Create Employee"), new Employee("Ram", "Create Employee"))
29+
.forEach(employee -> {
30+
employeeRepository.save(employee).subscribe(System.out::println);
31+
32+
});
33+
});
34+
};
35+
36+
}
37+
1338
public static void main(String[] args) {
1439
SpringApplication.run(WebfluxDemoApplication.class, args);
1540
}

0 commit comments

Comments
 (0)