spring.jpa.hibernate.ddl-auto=create之所以停止工作,不是因为你有两个DataSource,而是因为你的应用程序正在创建自己
LocalContainerEntityManagerFactoryBean的。这具有禁用a的自动配置的效果,
LocalContainerEntityManagerFactoryBean因此你现在必须自己配置它。
你可以将两个实体管理器配置为具有不同的架构生成行为,如下所示(第一个进行更新,第二个进行创建):
@Bean(name = "externalEntityManagerFactory")public LocalContainerEntityManagerFactoryBean externalEntityManagerFactory( EntityManagerFactoryBuilder builder) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("hibernate.hbm2ddl.auto", "update"); return builder .dataSource(externalDataSource()) .packages("cz.data.external.entity") .persistenceUnit(EXTERNAL) .properties(properties) .build();}@Bean(name = "internalEntityManagerFactory")@Primarypublic LocalContainerEntityManagerFactoryBean internalEntityManagerFactory( EntityManagerFactoryBuilder builder) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("hibernate.hbm2ddl.auto", "create"); return builder .dataSource(internalDataSource()) .packages("cz.data.internal.entity") .persistenceUnit(INTERNAL) .properties(properties) .build();}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)