Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument

前端 未结 2 856
灰色年华
灰色年华 2021-01-20 17:23

I just migrate to spring JPA technology and manage to change my simple jersey-hibernate project to spring JPA with custom crudrepository. But I can\'t deal with auto config

相关标签:
2条回答
  • 2021-01-20 17:49

    If you are using Hibernate, you have to provide most basic hibernate object (or bean in spring) called EntityManagerFactory to manage db sessions. This may be helpful : Obtaining EntityManager in Spring + Hibernate configuration

    0 讨论(0)
  • 2021-01-20 18:03

    Exception says that there is no bean with name entityManagerFactory, Place a debug point in

    public LocalContainerEntityManagerFactoryBean entityManagerFactory(
                EntityManagerFactoryBuilder factoryBuilder)
    

    method org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.class and check why the bean is not getting initiated.

    Oh, From discussion I came to the conclusion that mentioned issue is due to hibernate older dependencies. Also, the @Id which was imported needs to be from javax.persistence.id for all your entities.

    0 讨论(0)
提交回复
热议问题