Skip to content

Instantly share code, notes, and snippets.

@sophea
Last active February 3, 2020 09:41
Show Gist options
  • Save sophea/88410270d7bba8ddbfdcf20f4b770335 to your computer and use it in GitHub Desktop.
Save sophea/88410270d7bba8ddbfdcf20f4b770335 to your computer and use it in GitHub Desktop.
OracleDatabaseConfiguration
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(entityManagerFactoryRef = "oracleEntityManagerFactory", transactionManagerRef = "oracleTransactionManager", basePackages = { "com.sma.oracle.repository" })
public class OracleDatabaseConfiguration {
@Primary
@Bean
@ConfigurationProperties(prefix = "oracle.datasource")
public DataSourceProperties oracleDataSourceProperties(@Qualifier("oracleDataSourceProperties() {
return new DataSourceProperties();
}
@Primary
@Bean
public DataSource oracleDataSource(@Qualifier("oracleDataSourceProperties") DataSourceProperties dataSourceProperties) {
return dataSourceProperties.initializeDataSourceBuilder().build();
}
@Primary
@Bean
public LocalContainerEntityManagerFactoryBean oracleEntityManagerFactory(@Qualifier("oracleDataSource") DataSource oracleDataSource, EntityManagerFactoryBuilder builder) {
return builder.dataSource(oracleDataSource).packages("com.sma.oracle.entity").persistenceUnit("oracle").build();
}
@Primary
@Bean
public PlatformTransactionManager oracleTransactionManager(@Qualifier("oracleEntityManagerFactory") EntityManagerFactory factory) {
return new JpaTransactionManager(factory);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment