Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-25-2022 11:05 AM
We are trying to configure two different neo4j db instance of same URI in reactive spring boot application. We have configured two different configuration as well. One of the configuration mentioned below but it's not detecting the configuration rather it's only considered what database mentioned in application.yml file i.e. spring.data.neo4j.database. If we don't mentioned this in yml file then it's inserting into default neo4j db. Although we have hardcoded the db in configuration file but it's not picking that.
@Configuration(proxyBeanMethods = false)
@EnableReactiveNeo4jRepositories(
basePackageClasses = OceanNeo4jConfiguration.class,
neo4jMappingContextRef = "oceanContext",
transactionManagerRef = "oceanManager")
@Slf4j
public class OceanNeo4jConfiguration {
@Bean
@Primary
public Driver oceanDriver(Neo4jProperties oceanProperties) {
var authentication = oceanProperties.getAuthentication();
return GraphDatabase.driver(oceanProperties.getUri(), AuthTokens.basic(
authentication.getUsername(), authentication
.getPassword()),
Config.builder()
.withMaxConnectionLifetime(3, TimeUnit.MINUTES)
.build());
}
@Bean
@Primary
public ReactiveTransactionManager oceanManager(
Driver driver,
ReactiveDatabaseSelectionProvider oceanSelection) {
return new ReactiveNeo4jTransactionManager(driver, oceanSelection);
}
@Bean
@Primary
public ReactiveDatabaseSelectionProvider oceanSelection(
Neo4jDataProperties oceanDataProperties) {
return () -> Mono.just(DatabaseSelection.byName("ocean"));
}
@Bean
@Primary
public Neo4jMappingContext oceanContext(ResourceLoader resourceLoader, Neo4jConversions neo4jConversions)
throws ClassNotFoundException {
Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions);
context.setInitialEntitySet(Neo4jEntityScanner.get(resourceLoader).scan(this.getClass().getPackageName()));
return context;
}```
All the sessions of the conference are now available online