From 27af908b992620c3f542aa41e6079613a4c555e9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 14 Oct 2020 13:39:38 +0200 Subject: [PATCH] Note that a Neo4j reactive transaction manager is not auto-configured Closes gh-23629 --- .../spring-boot-docs/build.gradle | 1 + .../docs/asciidoc/spring-boot-features.adoc | 11 +++++ ...eo4jReactiveTransactionManagerExample.java | 43 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index bf2861e22ae..db85f35864c 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -82,6 +82,7 @@ dependencies { implementation("org.springframework:spring-web") implementation("org.springframework:spring-webflux") implementation("org.springframework.data:spring-data-couchbase") + implementation("org.springframework.data:spring-data-neo4j") implementation("org.springframework.data:spring-data-redis") implementation("org.springframework.data:spring-data-r2dbc") implementation("org.springframework.kafka:spring-kafka") diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 57e36e35f56..a716d8d388f 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -4791,6 +4791,17 @@ When Project Reactor is available on the classpath, the reactive style is also a You can customize the locations to look for repositories and entities by using `@EnableNeo4jRepositories` and `@EntityScan` respectively on a `@Configuration`-bean. +[NOTE] +==== +In an application using the reactive style, a `ReactiveTransactionManager` is not auto-configured. +To enable transaction management, the following bean must be defined in your configuration: + +[source,java,indent=0] +---- +include::{code-examples}/neo4j/Neo4jReactiveTransactionManagerExample.java[tag=configuration] +---- +==== + [[boot-features-solr]] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java new file mode 100644 index 00000000000..81a95ce5d67 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2020 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.neo4j; + +import org.neo4j.driver.Driver; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; +import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; +import org.springframework.transaction.ReactiveTransactionManager; + +/** + * Example to show user-defined registration of a {@link ReactiveTransactionManager}. + * + * @author Stephane Nicoll + */ +@Configuration(proxyBeanMethods = false) +public class Neo4jReactiveTransactionManagerExample { + + // tag::configuration[] + @Bean + public ReactiveNeo4jTransactionManager reactiveTransactionManager(Driver driver, + ReactiveDatabaseSelectionProvider databaseNameProvider) { + return new ReactiveNeo4jTransactionManager(driver, databaseNameProvider); + } + // end::configuration[] + +}