I tried to write integration test using annotation @DataJpaTest . I have two datasource: Primary and secondary (class config) in result i have an error:
expected single matching bean but found 2: primaryDataSource,secondary then i tried to add a annotation
@AutoConfigureTestDatabase(replace= AutoConfigureTestDatabase.Replace.AUTO_CONFIGURED) and With AUTO_CONFIGURED only DataSources configured by properties will be replaced but instead embedded h2 i saw Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
how using @DataJpaTest with multiple datasources ?
public class DataSourcesConfig { @Bean @Primary @ConfigurationProperties(prefix="spring.datasource") public DataSource primaryDataSource() { return DataSourceBuilder.create().build(); } @Bean(name = "secondary") @ConfigurationProperties(prefix="datasource.secondary") public DataSource secondaryDataSource() { return DataSourceBuilder.create().build(); } }