Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 我们可以在spring boot中对同一个数据库进行多个配置吗_Spring Boot_Spring Data Jpa - Fatal编程技术网

Spring boot 我们可以在spring boot中对同一个数据库进行多个配置吗

Spring boot 我们可以在spring boot中对同一个数据库进行多个配置吗,spring-boot,spring-data-jpa,Spring Boot,Spring Data Jpa,我正在从事一个项目,其中一个公共模块是抽象的(公共的),它使用JPA存储库 然后我让uber jar公共模块开始在另一个spring启动项目(客户端)中使用,该项目也使用自己的JPA存储库 我需要的公共和客户端配置是相同的 然而问题是 如果我在客户机的配置中提到公共的存储库和实体包,那么客户机存储库的bean就没有得到构建 @EnableJpaRepositories(basePackages = {"COMMON_REPO, CLIENT_REPO" }) //failing to const

我正在从事一个项目,其中一个公共模块是抽象的(公共的),它使用JPA存储库

然后我让uber jar公共模块开始在另一个spring启动项目(客户端)中使用,该项目也使用自己的JPA存储库

我需要的公共和客户端配置是相同的

然而问题是

如果我在客户机的配置中提到公共的存储库和实体包,那么客户机存储库的bean就没有得到构建

@EnableJpaRepositories(basePackages = {"COMMON_REPO, CLIENT_REPO" }) //failing to construct CLIENT repo bean
如果我使用与客户机相同的数据源凭据为COMMON定义一个新配置,则不会创建COMMON存储库的bean

//Configuration-1
@EnableJpaRepositories(basePackages = {"COMMON_REPO" })...

//Configuraton-2 same as Configuration-1
@EnableJpaRepositories(basePackages = {"CLIENT_REPO" })... 

// COMMON repo bean is not getting constructed.

Error: Error creating bean with name 'workflowRepository': Cannot create inner bean '(inner bean)#60410fb3' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#60410fb3': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

Sprint启动版本:2.0.4。发布版

在spring启动中,可以对同一数据库进行多种配置

将两个不同的类用于带有@Profile注释的配置-1和配置-2,在@Profile中指定环境或配置


根据您部署应用程序的环境,配置文件将处于活动状态。

两者都将部署在同一环境中,因为这是客户端使用的jar