I'm making mongo to postgres migraiton tool with springboot. But when I try to connect with mongo and postgres base on this documents, spring just raise dataSource or dataSourceClassName or jdbcUrl is required. error.
this is my application.yml
spring:
datasource:
legacy:
url: "jdbc:postgresql://localhost:5432/postgres"
username: "root"
password: "root"
migration:
url: "jdbc:mongodb://localhost:27017"
username: "root"
password: "root"
database: "fromdb"
and to use two different types of DBMS, I config my configurations. (If it doesn't required, please let me know better way) and because of hibernate.dialect doesn't support MongoDBDialect, it also raise Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set error.
this is my legacy db configuration code
import part
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "migrationEntityManager",
transactionManagerRef = "migrationTransactionManager",
basePackages = "com.dbmigrater.DBMigrater.repository.migration"
)
public class MigrationDBConfig {
@Bean
@Primary
@ConfigurationProperties("spring.datasource.hikari.bootdb1")
public DataSource migrationDataSource() {
return DataSourceBuilder.create().build();
}
@Bean
@Primary
public PlatformTransactionManager migrationTransactionManager() {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(migrationEntityManager().getObject());
return transactionManager;
}
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean migrationEntityManager() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(migrationDataSource());
em.setPackagesToScan("com.dbmigrater.model.migration");
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(adapter);
Map<String, Object> properties = new HashMap<>();
properties.put("hibernate.physical_naming_strategy", SpringPhysicalNamingStrategy.class.getName());
properties.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName());
//=================This part is setting dialect, and error=====================//
properties.put("hibernate.dialect", org.hibernate.dialect.MongoDBDialect);
//=============================================================================//
em.setJpaPropertyMap(properties);
return em;
}
}
Because mentioned error, I should set dedicated part in my upper code. but it also causes errorproperties.put("hibernate.dialect", org.hibernate.dialect.MongoDBDialect); because hibernate.dialect does not support MongoDBDialect!!
How can I connect these two databases(mongo, postgres)??