@SpringBootApplication
public class ReactiveCouchbaseExample1Application {
@Bean
CommandLineRunner employees(ApplicationContext context) {
EmployeeRepository repository = context.getBean(EmployeeRepository.class);
return args -> {
repository
.deleteAll()
.subscribe(null,null,()->{
Stream.of(new Employees(UUID.randomUUID().toString(), "Nikhil", 23, 3000L),
new Employees(UUID.randomUUID().toString(), "Shubham", 23, 3000L),
new Employees(UUID.randomUUID().toString(), "Anshul", 23, 3000L))
.forEach(employee->{
repository.save(employee)
.subscribe(System.out::println);
});
});
};
}
public static void main(String[] args) {
SpringApplication.run(ReactiveCouchbaseExample1Application.class, args);
}
I wants to run this piece of logic as soon my application context get loaded but when i started my app it shows this error.
Method employees in com.reactive.reactivecouchbaseexample1.ReactiveCouchbaseExample1Application required a bean of type 'com.reactive.repository.EmployeeRepository' that could not be found.
Can someone tell me how can I create a repository bean inside CommandLineRunner. I also googled it but could'nt find any answers.
This is my repository
@Repository
public interface EmployeeRepository extends
ReactiveCouchbaseRepository<Employees, String>{
}