Last active
February 3, 2020 09:41
-
-
Save sophea/88410270d7bba8ddbfdcf20f4b770335 to your computer and use it in GitHub Desktop.
OracleDatabaseConfiguration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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