diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java index 02aa2b92a3..1d204ddcb1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java @@ -94,15 +94,14 @@ public class Neo4jDataAutoConfiguration { @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME) @ConditionalOnMissingBean - public Neo4jClient neo4jClient(Driver driver) { - return Neo4jClient.create(driver); + public Neo4jClient neo4jClient(Driver driver, DatabaseSelectionProvider databaseNameProvider) { + return Neo4jClient.create(driver, databaseNameProvider); } @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME) @ConditionalOnMissingBean(Neo4jOperations.class) - public Neo4jTemplate neo4jTemplate(Neo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext, - DatabaseSelectionProvider databaseNameProvider) { - return new Neo4jTemplate(neo4jClient, neo4jMappingContext, databaseNameProvider); + public Neo4jTemplate neo4jTemplate(Neo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext) { + return new Neo4jTemplate(neo4jClient, neo4jMappingContext); } @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfiguration.java index 1ef6b3d10d..38dcf4e501 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,15 +58,16 @@ public class Neo4jReactiveDataAutoConfiguration { @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME) @ConditionalOnMissingBean - public ReactiveNeo4jClient reactiveNeo4jClient(Driver driver) { - return ReactiveNeo4jClient.create(driver); + public ReactiveNeo4jClient reactiveNeo4jClient(Driver driver, + ReactiveDatabaseSelectionProvider databaseNameProvider) { + return ReactiveNeo4jClient.create(driver, databaseNameProvider); } @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME) @ConditionalOnMissingBean(ReactiveNeo4jOperations.class) public ReactiveNeo4jTemplate reactiveNeo4jTemplate(ReactiveNeo4jClient neo4jClient, - Neo4jMappingContext neo4jMappingContext, ReactiveDatabaseSelectionProvider databaseNameProvider) { - return new ReactiveNeo4jTemplate(neo4jClient, neo4jMappingContext, databaseNameProvider); + Neo4jMappingContext neo4jMappingContext) { + return new ReactiveNeo4jTemplate(neo4jClient, neo4jMappingContext); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java index 52c42d0d65..c5b46119ea 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfigurationTests.java @@ -97,6 +97,15 @@ class Neo4jDataAutoConfigurationTests { this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Neo4jClient.class)); } + @Test + void shouldProvideNeo4jClientWithCustomDatabaseSelectionProvider() { + this.contextRunner.withUserConfiguration(CustomDatabaseSelectionProviderConfiguration.class).run((context) -> { + assertThat(context).hasSingleBean(Neo4jClient.class); + assertThat(context.getBean(Neo4jClient.class)).extracting("databaseSelectionProvider") + .isSameAs(context.getBean(DatabaseSelectionProvider.class)); + }); + } + @Test void shouldReuseExistingNeo4jClient() { this.contextRunner.withBean("myCustomClient", Neo4jClient.class, () -> mock(Neo4jClient.class)) @@ -105,11 +114,8 @@ class Neo4jDataAutoConfigurationTests { @Test void shouldProvideNeo4jTemplate() { - this.contextRunner.withUserConfiguration(CustomDatabaseSelectionProviderConfiguration.class).run((context) -> { - assertThat(context).hasSingleBean(Neo4jTemplate.class); - assertThat(context.getBean(Neo4jTemplate.class)).extracting("databaseSelectionProvider") - .isSameAs(context.getBean(DatabaseSelectionProvider.class)); - }); + this.contextRunner.withUserConfiguration(CustomDatabaseSelectionProviderConfiguration.class) + .run((context) -> assertThat(context).hasSingleBean(Neo4jTemplate.class)); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java index d896ab1a4e..e04690355f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfigurationTests.java @@ -91,6 +91,16 @@ class Neo4jReactiveDataAutoConfigurationTests { this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ReactiveNeo4jClient.class)); } + @Test + void shouldProvideReactiveNeo4jClientWithCustomDatabaseSelectionProvider() { + this.contextRunner.withUserConfiguration(CustomReactiveDatabaseSelectionProviderConfiguration.class) + .run((context) -> { + assertThat(context).hasSingleBean(ReactiveNeo4jClient.class); + assertThat(context.getBean(ReactiveNeo4jClient.class)).extracting("databaseSelectionProvider") + .isSameAs(context.getBean(ReactiveDatabaseSelectionProvider.class)); + }); + } + @Test void shouldReuseExistingReactiveNeo4jClient() { this.contextRunner @@ -102,11 +112,7 @@ class Neo4jReactiveDataAutoConfigurationTests { @Test void shouldProvideReactiveNeo4jTemplate() { this.contextRunner.withUserConfiguration(CustomReactiveDatabaseSelectionProviderConfiguration.class) - .run((context) -> { - assertThat(context).hasSingleBean(ReactiveNeo4jTemplate.class); - assertThat(context.getBean(ReactiveNeo4jTemplate.class)).extracting("databaseSelectionProvider") - .isSameAs(context.getBean(ReactiveDatabaseSelectionProvider.class)); - }); + .run((context) -> assertThat(context).hasSingleBean(ReactiveNeo4jTemplate.class)); } @Test diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index d0ba0524b2..6e2fd242e2 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1621,7 +1621,7 @@ bom { ] } } - library("Spring Data Bom", "2021.0.0-M4") { + library("Spring Data Bom", "2021.0.0-SNAPSHOT") { group("org.springframework.data") { imports = [ "spring-data-bom"