From eeddf9a73a3744334692859e47ab6f764d6e5fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 9 Mar 2026 10:11:29 +0100 Subject: [PATCH] Fix transaction managemement snippet and documentation Closes gh-36323 --- .../transaction/declarative/annotations.adoc | 28 ++----------------- .../AppConfig.java | 2 +- .../DefaultFooService.java | 20 +++++++++++++ .../FooService.java | 20 +++++++++++++ .../AppConfig.kt | 2 +- .../DefaultFooService.kt | 20 +++++++++++++ .../FooService.kt | 20 +++++++++++++ .../AppConfig.xml} | 2 +- 8 files changed, 86 insertions(+), 28 deletions(-) rename framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/{annotations => transactiondeclarativeannotations}/AppConfig.java (97%) create mode 100644 framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.java create mode 100644 framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.java rename framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/{annotations => transactiondeclarativeannotations}/AppConfig.kt (97%) create mode 100644 framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.kt create mode 100644 framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.kt rename framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/{annotations/annotations-tx.xml => transactiondeclarativeannotations/AppConfig.xml} (94%) diff --git a/framework-docs/modules/ROOT/pages/data-access/transaction/declarative/annotations.adoc b/framework-docs/modules/ROOT/pages/data-access/transaction/declarative/annotations.adoc index d37ebe58907..b94b778a6e5 100644 --- a/framework-docs/modules/ROOT/pages/data-access/transaction/declarative/annotations.adoc +++ b/framework-docs/modules/ROOT/pages/data-access/transaction/declarative/annotations.adoc @@ -89,34 +89,12 @@ annotation in a `@Configuration` class. See the {spring-framework-api}/transaction/annotation/EnableTransactionManagement.html[javadoc] for full details. -The following examples show the configuration needed to enable annotation-driven transaction management: +The following example show the configuration needed to enable annotation-driven transaction management: -[tabs] -====== -Java:: -+ -[source,java,indent=0,subs="verbatim,quotes",role="primary"] ----- -include-code::AppConfig[] ----- - -Kotlin:: -+ -[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"] ----- -include-code::AppConfig[] ----- - -XML:: -+ -[source,xml,indent=0,subs="verbatim,quotes",role="secondary"] ----- -include-code::annotations-tx[tags=snippet] ----- -====== +include-code::./AppConfig[tag=snippet,indent=0] TIP: In programmatic configuration, the `@EnableTransactionManagement` annotation uses any -`PlatformTransactionManager` bean in the context. In XML configuration, you can omit +`TransactionManager` bean in the context. In XML configuration, you can omit the `transaction-manager` attribute in the `` tag if the bean name of the `TransactionManager` that you want to wire in has the name `transactionManager`. If the `TransactionManager` bean has any other name, you have to use the diff --git a/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/annotations/AppConfig.java b/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.java similarity index 97% rename from framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/annotations/AppConfig.java rename to framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.java index e0a22ef0209..8d5cebe5efa 100644 --- a/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/annotations/AppConfig.java +++ b/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.docs.dataaccess.transaction.declarative.annotations; +package org.springframework.docs.dataaccess.transaction.declarative.transactiondeclarativeannotations; import javax.sql.DataSource; diff --git a/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.java b/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.java new file mode 100644 index 00000000000..8ccceaf3b47 --- /dev/null +++ b/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.java @@ -0,0 +1,20 @@ +/* + * Copyright 2002-present 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.docs.dataaccess.transaction.declarative.transactiondeclarativeannotations; + +public class DefaultFooService implements FooService { +} diff --git a/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.java b/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.java new file mode 100644 index 00000000000..95841a510c9 --- /dev/null +++ b/framework-docs/src/main/java/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.java @@ -0,0 +1,20 @@ +/* + * Copyright 2002-present 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.docs.dataaccess.transaction.declarative.transactiondeclarativeannotations; + +public interface FooService { +} diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/annotations/AppConfig.kt b/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.kt similarity index 97% rename from framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/annotations/AppConfig.kt rename to framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.kt index 6b98477bb31..cba3522fb4c 100644 --- a/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/annotations/AppConfig.kt +++ b/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.docs.dataaccess.transaction.declarative.annotations +package org.springframework.docs.dataaccess.transaction.declarative.transactiondeclarativeannotations import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.kt b/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.kt new file mode 100644 index 00000000000..9fcccf51c48 --- /dev/null +++ b/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/DefaultFooService.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2002-present 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.docs.dataaccess.transaction.declarative.transactiondeclarativeannotations + +class DefaultFooService : FooService { +} \ No newline at end of file diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.kt b/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.kt new file mode 100644 index 00000000000..7ee5d6ca08d --- /dev/null +++ b/framework-docs/src/main/kotlin/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/FooService.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2002-present 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.docs.dataaccess.transaction.declarative.transactiondeclarativeannotations + +interface FooService { +} \ No newline at end of file diff --git a/framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/annotations/annotations-tx.xml b/framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.xml similarity index 94% rename from framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/annotations/annotations-tx.xml rename to framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.xml index ffc46184be0..55230b90c9c 100644 --- a/framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/annotations/annotations-tx.xml +++ b/framework-docs/src/main/resources/org/springframework/docs/dataaccess/transaction/declarative/transactiondeclarativeannotations/AppConfig.xml @@ -17,7 +17,7 @@ - +