Consider defining a bean of type in your configuration
In my case , I was getting same error using mysql db
solved using @EnableJpaRepositories
@SpringBootApplication
@ComponentScan("com.example.repositories")//to scan repository files
@EntityScan("com.example.entities")
@EnableJpaRepositories("com.example.repositories")
public class EmployeeApplication implements CommandLineRunner{ ..}
If you wish to avoid writing annotations you can simply change your packages com.mongotest.entities
to com.mongotest.demo.entities
and com.mongotest.repositories
to com.mongotest.demo.repositories
Spring Boot architecture will take care of rest. Actually other files and packages are supposed to be either at same level or below your DemoApplication.java
.
Please add below annotations in DemoApplication
@SpringBootApplication
@ComponentScan("com.mongotest") //to scan packages mentioned
@EnableMongoRepositories("com.mongotest") //to activate MongoDB repositories
public class DemoApplication { ... }