Spring Data JPA - Consider defining a bean named 'entityManagerFactory' in your configuration

后端 未结 9 2227
一个人的身影
一个人的身影 2020-12-29 05:24

I am developing an application in Spring, using Tomcat, Mysql5, Java8... The problem is that I cannot deploy it, due to \"required bean \'entityManagerFactory\' not found\"

9条回答
  •  轮回少年
    2020-12-29 05:41

    You are missing repository configuration, as you have to configure it using @Repository,

    Following is incorrect,

    public interface UsuarioRepository  extends JpaRepository {
    

    Rather it should be configured as repository as follows,

    @Repository
    public interface UsuarioRepository  extends JpaRepository {
    

    This will make it a bean to be scanned and treat it as a repository and then your following code should work as expected as well,

    @Autowired
    private UsuarioRepository usuarioDao;
    

提交回复
热议问题