cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Reactive + Spring boot + Neo4j multiple db - unable to detect customized driver configuration

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;
    }```
0 REPLIES 0