Estou unificando dois projetos springboot que apontavam cada um para um banco de dados em um único projeto monolítico, usando a seguinte configurações abaixo:
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "oracleEntityManagerFactory",
transactionManagerRef = "oracleTransactionManager",
basePackages = {"br.com.nuvemapi.aprovacaoDesconto.repositories",
"br.com.nuvemapi.aprovacaoTransferenciaVolante.repositories",
"br.com.nuvemapi.aprovacoes.repositories",
"br.com.nuvemapi.controleAtividades.repositories",
"br.com.nuvemapi.core.repositories",
"br.com.nuvemapi.postosCredenciados.repositories",
"br.com.nuvemapi.seguranca.repositories",
"br.com.nuvemapi.acompanhamentoCompras.repositories",
"br.com.nuvemapi.aprovacaoCompras.repositories",
"br.com.nuvemapi.aprovacaoDescontoRetirada.repositories",
"br.com.nuvemapi.producaoTecnicos.repositories"
}
)
public class OracleDatasourceConfig {
@Primary
@Bean(name = "oracleDataSourceProperties")
@ConfigurationProperties("oracle.datasource")
public DataSourceProperties oracleDataSourceProperties() {
return new DataSourceProperties();
}
@Primary
@Bean(name = "oracleDataSource")
public HikariDataSource oracleDataSource() {
return oracleDataSourceProperties()
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
@Primary
@Bean(name = "oracleEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder oracleEntityManagerFactory,
@Qualifier("oracleDataSource") DataSource oracleDataSource) {
return oracleEntityManagerFactory
.dataSource(oracleDataSource)
.persistenceUnit("oraclePU")
.packages("br.com.nuvemapi.aprovacaoDesconto.entities",
"br.com.nuvemapi.aprovacaoTransferenciaVolante.entities",
"br.com.nuvemapi.aprovacoes.entities",
"br.com.nuvemapi.controleAtividades.entities",
"br.com.nuvemapi.core.entities",
"br.com.nuvemapi.postosCredenciados.entities",
"br.com.nuvemapi.seguranca.entities",
"br.com.nuvemapi.acompanhamentoCompras.entities",
"br.com.nuvemapi.aprovacaoCompras.entities",
"br.com.nuvemapi.aprovacaoDescontoRetirada.entities",
"br.com.nuvemapi.producaoTecnicos.entities")
.build();
}
@Primary
@Bean(name = "oracleTransactionManager")
public PlatformTransactionManager oracleTransactionManager(
@Qualifier("oracleEntityManagerFactory") EntityManagerFactory oracleEntityManagerFactory) {
return new JpaTransactionManager(oracleEntityManagerFactory);
}
}
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "sqlServerEntityManagerFactory",
transactionManagerRef = "sqlServerTransactionManager",
basePackages = "br.com.nuvemapi.integrador.repositories")
public class SqlServerDatasourceConfig {
@Bean(name = "sqlServerDataSourceProperties")
@ConfigurationProperties("sqlserver.datasource")
public DataSourceProperties sqlServerDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "sqlServerDataSource")
public HikariDataSource sqlServerDataSource() {
return sqlServerDataSourceProperties()
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
@Bean(name = "sqlServerEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder sqlServerEntityManagerFactory,
@Qualifier("sqlServerDataSource") DataSource sqlServerDataSource) {
return sqlServerEntityManagerFactory
.dataSource(sqlServerDataSource)
.packages("br.com.nuvemapi.integrador.entities")
.persistenceUnit("sqlServerPU")
.build();
}
@Bean(name = "sqlServerTransactionManager")
public PlatformTransactionManager sqlServerTransactionManager(
@Qualifier("sqlServerEntityManagerFactory") EntityManagerFactory sqlServerEntityManagerFactory) {
return new JpaTransactionManager(sqlServerEntityManagerFactory);
}
}
O projeto esta subindo sem apresentar nenhum erro, porem ao tentar cosumir um endpoint de um entitadade que possui dois mapeamento @OneToMany recebo o erro do titulo da pergunta.