Spring Boot 2.0.0.M4 & Hibernate 5.2.11.Final could not find bean of type EntityManagerFactoryBuilder

前端 未结 2 1415
粉色の甜心
粉色の甜心 2021-01-06 04:03

I have clearly what seems to be some configuration issue, but I\'ve been unable to resolve this myself. I have hope you guys could help me?

None of the examples I fi

2条回答
  •  轮回少年
    2021-01-06 04:37

    By excluding HibernateJpaAutoConfiguration you are turning off creating EntityManagerFactoryBuilder bean.

    By default EntityManagerFactoryBuilder bean is produced by JpaBaseConfiguration#entityManagerFactoryBuilder(JpaVendorAdapter, ObjectProvider).

    There is only one JpaBaseConfiguration implementation - HibernateJpaConfiguration, which is activated if:

    • there is only one DataSource candidate (or one is marked as @Primary);
    • HibernateJpaAutoConfiguration conditions are true - check HibernateJpaAutoConfiguration class.

    You should either create and configure LocalContainerEntityManagerFactoryBean without builder (like you did in your own answer), or create EntityManagerFactoryBuilder in your configuration manually like this:

    @Bean
    public EntityManagerFactoryBuilder entityManagerFactoryBuilder() {
        return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), new HashMap<>(), null);
    }
    

提交回复
热议问题