Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @EnableTransactionManagement
- @EnableJpaRepositories(
- entityManagerFactoryRef = "entityManagerFactory",
- basePackages = "com.evli.kickback.database.local.repository"
- )
- public class LocalDatabaseConfig {
- @Bean(name = "dataSource")
- @ConfigurationProperties(prefix = "spring.datasource")
- public DataSource dataSource() {
- return DataSourceBuilder.create().build();
- }
- @Bean(name = "entityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(EntityManagerFactoryBuilder builder, @Qualifier("dataSource") DataSource dataSource) {
- return builder.dataSource(dataSource)
- .packages("com.xxx.xxx")
- .persistenceUnit("local")
- .build();
- }
- @Bean(name = "transactionManager")
- public PlatformTransactionManager transactionManager(@Qualifier("entityManagerFactory")EntityManagerFactory entityManagerFactory) {
- return new JpaTransactionManager(entityManagerFactory);
- }
- }
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'XXXX.XXX' doesn't exist
- import javax.persistence.EntityManagerFactory;
- import javax.sql.DataSource;
- @Configuration
- @EnableJpaRepositories(
- entityManagerFactoryRef = "realEntityManagerFactory",
- transactionManagerRef = "realTransactionManager",
- basePackages = {"com.xxx.xxx"})
- public class DatabaseConfig {
- @Primary
- @Bean(name = "dataSource")
- @ConfigurationProperties(prefix = "real.datasource")
- public DataSource dataSource() {
- return DataSourceBuilder.create().build();
- }
- @Primary
- @Bean
- public LocalContainerEntityManagerFactoryBean realEntityManagerFactory(EntityManagerFactoryBuilder builder) {
- LocalContainerEntityManagerFactoryBean emf = builder.dataSource(dataSource())
- .packages("com.xxx.xxx")
- .persistenceUnit("real")
- .build();
- return emf;
- }
- @Primary
- @Bean
- public PlatformTransactionManager realTransactionManager(@Qualifier("realEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
- return new JpaTransactionManager(entityManagerFactory);
- }
- }
- real.datasource.jdbc-url=jdbc:oracle:thin:xxxxxxx
- real.datasource.username=xxxxx
- real.datasource.password=xxxxx
- real.datasource.driver-class-name=oracle.jdbc.OracleDriver
- spring.datasource.jdbc-url=jdbc:mysql://localhost:xxxxx
- spring.datasource.username=xxxx
- spring.datasource.password=xxxx
- spring.jpa.database=default
Add Comment
Please, Sign In to add comment