Spring @Autowired can not wire Jpa repository

后端 未结 1 1713
面向向阳花
面向向阳花 2021-01-11 19:36

I clearly missing something here. I\'m making a simple spring boot app with spring data jpa inluded and face follwing error:

Caused         


        
相关标签:
1条回答
  • 2021-01-11 19:52

    I also had the same problem.I solved it with following solution. If your Entity classes and Repositories in a different package you need to use following annotations.

    @SpringBootApplication
    @EntityScan(basePackages = {"EntityPackage"} )
    @EnableJpaRepositories(basePackages = {"RepositoryPackage"})
    public class Application {
    
        public static void main(String[] args) {
    
            SpringApplication.run(Application.class, args);
    
        }
    }
    
    0 讨论(0)
提交回复
热议问题