From 0cf31e243331a8478debd25d8764265d6b0deba2 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Fri, 1 Aug 2025 12:05:25 -0400 Subject: [PATCH 1/3] Add multiple datasource how to for spring data jdbc Signed-off-by: Daniel Frey --- jdbc/howto/multiple-datasources/README.adoc | 9 ++ jdbc/howto/multiple-datasources/pom.xml | 50 +++++++ .../howto/multipledatasources/EvilEmpire.java | 37 +++++ .../MultipleDataSourceApplication.java | 13 ++ .../DataSourceConfiguration.java | 131 ++++++++++++++++++ .../configuration/JdbcConfiguration.java | 29 ++++ .../multipledatasources/minion/Minion.java | 29 ++++ .../minion/MinionRepository.java | 29 ++++ .../multipledatasources/person/Person.java | 27 ++++ .../person/PersonRepository.java | 22 +++ .../src/main/resources/application.properties | 0 .../src/main/resources/ds1-data.sql | 6 + .../src/main/resources/ds1-schema.sql | 7 + .../src/main/resources/ds2-data.sql | 2 + .../src/main/resources/ds2-schema.sql | 6 + .../multipledatasources/EvilEmpireTests.java | 35 +++++ .../MultipleDataSourceApplicationTests.java | 18 +++ jdbc/howto/pom.xml | 1 + pom.xml | 2 +- 19 files changed, 452 insertions(+), 1 deletion(-) create mode 100644 jdbc/howto/multiple-datasources/README.adoc create mode 100644 jdbc/howto/multiple-datasources/pom.xml create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java create mode 100644 jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java create mode 100644 jdbc/howto/multiple-datasources/src/main/resources/application.properties create mode 100644 jdbc/howto/multiple-datasources/src/main/resources/ds1-data.sql create mode 100644 jdbc/howto/multiple-datasources/src/main/resources/ds1-schema.sql create mode 100644 jdbc/howto/multiple-datasources/src/main/resources/ds2-data.sql create mode 100644 jdbc/howto/multiple-datasources/src/main/resources/ds2-schema.sql create mode 100644 jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java create mode 100644 jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java diff --git a/jdbc/howto/multiple-datasources/README.adoc b/jdbc/howto/multiple-datasources/README.adoc new file mode 100644 index 000000000..9724f23a8 --- /dev/null +++ b/jdbc/howto/multiple-datasources/README.adoc @@ -0,0 +1,9 @@ +== Spring Data JDBC How To use multiple DataSources. + +Spring Data JDBC requires special configuration if multiple DataSources are to be present in the ApplicationContext. + +Configuration is provided to setup two DataSources, each with their own schema and data files. Review the `DataSourceConfiguration` class for this configuration. Note that the first DataSource configuration utilizes Spring Data JDBC's automatic configuration, whereas the second DataSource explicitly disables the AutoConfiguration so that Beans can be manually created. + +The Beans created in `DataSourceConfiguration`, notably, the `NamedParameterJdbcOperations` and `TransactionManager` instances are then referenced in the `@EnableJdbcRepositories` configuration. Specifically, you specify the `jdbcOperationsRef` and `transactionManagerRef`. Please review the `JdbcConfiguration` class. + +A sample `Service` is provided to bring together two Spring Data JDBC Repositories that are backed by different DataSources. Review the `EvilEmpire` Component and corresponding `EvilEmpireTests` classes. diff --git a/jdbc/howto/multiple-datasources/pom.xml b/jdbc/howto/multiple-datasources/pom.xml new file mode 100644 index 000000000..68bb6e7c3 --- /dev/null +++ b/jdbc/howto/multiple-datasources/pom.xml @@ -0,0 +1,50 @@ + + 4.0.0 + + spring-data-jdbc-how-to-multiple-datasources + + + org.springframework.data.examples + spring-data-jdbc-how-to + 2.0.0.BUILD-SNAPSHOT + ../pom.xml + + + Spring Data JDBC - How to configure multiple datasources + Sample project for Spring Data JDBC demonstrating how to configure multiple datasources. + + https://projects.spring.io/spring-data-jdbc + 2025 + + + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + + com.h2database + h2 + runtime + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java new file mode 100644 index 000000000..8ddd276e4 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java @@ -0,0 +1,37 @@ +package example.springdata.jdbc.howto.multipledatasources; + +import example.springdata.jdbc.howto.multipledatasources.minion.Minion; +import example.springdata.jdbc.howto.multipledatasources.minion.MinionRepository; +import example.springdata.jdbc.howto.multipledatasources.person.PersonRepository; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class EvilEmpire { + + private final PersonRepository personRepository; + private final MinionRepository minionRepository; + + public EvilEmpire( PersonRepository personRepository, MinionRepository minionRepository ) { + + this.personRepository = personRepository; + this.minionRepository = minionRepository; + + } + + public List getMinionsByEvilMaster( Long evilMaster ) { + + var person = this.personRepository.findById( evilMaster ); + if ( person.isPresent() ) { + + return this.minionRepository.findByEvilMaster( person.get().id() ).stream() + .map( Minion::name ) + .toList(); + + } + + throw new IllegalArgumentException( "No Minions found for Evil Master [" + evilMaster + "]" ); + } + +} diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java new file mode 100644 index 000000000..437d88e7c --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java @@ -0,0 +1,13 @@ +package example.springdata.jdbc.howto.multipledatasources; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +class MultipleDataSourceApplication { + + public static void main(String[] args) { + SpringApplication.run(MultipleDataSourceApplication.class, args); + } + +} diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java new file mode 100644 index 000000000..a6d280679 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java @@ -0,0 +1,131 @@ +package example.springdata.jdbc.howto.multipledatasources.configuration; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.data.jdbc.core.convert.DefaultJdbcTypeFactory; +import org.springframework.data.jdbc.core.convert.JdbcConverter; +import org.springframework.data.jdbc.core.convert.JdbcCustomConversions; +import org.springframework.data.jdbc.core.convert.MappingJdbcConverter; +import org.springframework.data.jdbc.core.convert.RelationResolver; +import org.springframework.data.jdbc.core.dialect.DialectResolver; +import org.springframework.data.jdbc.core.dialect.JdbcDialect; +import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; +import org.springframework.data.relational.core.mapping.DefaultNamingStrategy; +import org.springframework.data.relational.core.mapping.NamingStrategy; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; +import java.util.Optional; + +@Configuration +public class DataSourceConfiguration { + + @Configuration + static class Ds1Configuration { + + @Bean("ds1") + DataSource dataSource1() { + + var builder = new EmbeddedDatabaseBuilder(); + + return builder + .setType( EmbeddedDatabaseType.H2 ) + .generateUniqueName( true ) + .addScript( "classpath:/ds1-schema.sql" ) + .addScript( "classpath:/ds1-data.sql" ) + .build(); + } + + @Bean("jdbcOperations1" ) + NamedParameterJdbcOperations jdbcOperations1() { + + return new NamedParameterJdbcTemplate( dataSource1() ); + } + + @Bean( "transactionManager1" ) + PlatformTransactionManager transactionManager1() { + + return new DataSourceTransactionManager( dataSource1() ); + } + + } + + @Configuration + @EnableAutoConfiguration(exclude = { + DataSourceAutoConfiguration.class, + JdbcRepositoriesAutoConfiguration.class + }) + static class Ds2Configuration { + + @Bean( "ds2" ) + DataSource dataSource2() { + + var builder = new EmbeddedDatabaseBuilder(); + + return builder + .setType( EmbeddedDatabaseType.H2 ) + .generateUniqueName( true ) + .addScript( "classpath:/ds2-schema.sql" ) + .addScript( "classpath:/ds2-data.sql" ) + .build(); + } + + @Bean( "jdbcOperations2" ) + NamedParameterJdbcOperations jdbcOperations1() { + + return new NamedParameterJdbcTemplate( dataSource2() ); + } + + @Bean( "transactionManager2" ) + PlatformTransactionManager transactionManager2() { + + return new DataSourceTransactionManager( dataSource2() ); + } + + @Bean + JdbcDialect jdbcDialect2( @Qualifier( "jdbcOperations2" ) NamedParameterJdbcOperations jdbcOperations ) { + + return DialectResolver.getDialect( jdbcOperations.getJdbcOperations() ); + } + + @Bean + JdbcCustomConversions customConversions2() { + + return new JdbcCustomConversions(); + } + + @Bean + JdbcMappingContext jdbcMappingContext2( Optional namingStrategy, JdbcCustomConversions customConversions2 ) { + + var mappingContext = new JdbcMappingContext( namingStrategy.orElse( DefaultNamingStrategy.INSTANCE ) ); + mappingContext.setSimpleTypeHolder( customConversions2.getSimpleTypeHolder() ); + + return mappingContext; + } + + @Bean + JdbcConverter jdbcConverter2( + JdbcMappingContext jdbcMappingContext2, + @Qualifier( "jdbcOperations2" ) NamedParameterJdbcOperations jdbcOperations2, + @Lazy RelationResolver relationResolver, + JdbcCustomConversions customConversions2 + ) { + + var jdbcTypeFactory = new DefaultJdbcTypeFactory( jdbcOperations2.getJdbcOperations() ); + + return new MappingJdbcConverter( jdbcMappingContext2, relationResolver, customConversions2, jdbcTypeFactory ); + } + + } + +} diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java new file mode 100644 index 000000000..a53c4e44d --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java @@ -0,0 +1,29 @@ +package example.springdata.jdbc.howto.multipledatasources.configuration; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; + +@Configuration +public class JdbcConfiguration { + + @Configuration + @EnableJdbcRepositories( + basePackages = { "example.springdata.jdbc.howto.multipledatasources.minion" }, + jdbcOperationsRef = "jdbcOperations1", + transactionManagerRef = "transactionManager1" + ) + static class MinionJdbcConfiguration { + + } + + @Configuration + @EnableJdbcRepositories( + basePackages = { "example.springdata.jdbc.howto.multipledatasources.person" }, + jdbcOperationsRef = "jdbcOperations2", + transactionManagerRef = "transactionManager2" + ) + static class PersonJdbcConfiguration { + + } + +} diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java new file mode 100644 index 000000000..eb3229657 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java @@ -0,0 +1,29 @@ +/* + * Copyright 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. + * 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 example.springdata.jdbc.howto.multipledatasources.minion; + +import org.springframework.data.annotation.Id; + +public record Minion( + + @Id + Long id, + + String name, + + Long evilMaster + +) { } diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java new file mode 100644 index 000000000..a4f3dc2d2 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java @@ -0,0 +1,29 @@ +/* + * Copyright 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. + * 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 example.springdata.jdbc.howto.multipledatasources.minion; + +import org.springframework.data.jdbc.repository.query.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.Collection; + +public interface MinionRepository extends CrudRepository { + + @Query( "SELECT * FROM MINION WHERE EVIL_MASTER = :id" ) + Collection findByEvilMaster( @Param( "id" ) Long id ); + +} diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java new file mode 100644 index 000000000..864a0e053 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java @@ -0,0 +1,27 @@ +/* + * Copyright 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. + * 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 example.springdata.jdbc.howto.multipledatasources.person; + +import org.springframework.data.annotation.Id; + +public record Person( + + @Id + Long id, + + String name + +) { } diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java new file mode 100644 index 000000000..301457926 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java @@ -0,0 +1,22 @@ +/* + * Copyright 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. + * 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 example.springdata.jdbc.howto.multipledatasources.person; + +import org.springframework.data.repository.CrudRepository; + +public interface PersonRepository extends CrudRepository { + +} diff --git a/jdbc/howto/multiple-datasources/src/main/resources/application.properties b/jdbc/howto/multiple-datasources/src/main/resources/application.properties new file mode 100644 index 000000000..e69de29bb diff --git a/jdbc/howto/multiple-datasources/src/main/resources/ds1-data.sql b/jdbc/howto/multiple-datasources/src/main/resources/ds1-data.sql new file mode 100644 index 000000000..2c484a68e --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/resources/ds1-data.sql @@ -0,0 +1,6 @@ + +INSERT INTO MINION (NAME, EVIL_MASTER) VALUES ('Stuart', 1); +INSERT INTO MINION (NAME, EVIL_MASTER) VALUES ('Donnie', 1); +INSERT INTO MINION (NAME, EVIL_MASTER) VALUES ('Bob', 1); +INSERT INTO MINION (NAME, EVIL_MASTER) VALUES ('Ken', 1); +INSERT INTO MINION (NAME, EVIL_MASTER) VALUES ('Kevin', 1); \ No newline at end of file diff --git a/jdbc/howto/multiple-datasources/src/main/resources/ds1-schema.sql b/jdbc/howto/multiple-datasources/src/main/resources/ds1-schema.sql new file mode 100644 index 000000000..dac1af949 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/resources/ds1-schema.sql @@ -0,0 +1,7 @@ + +CREATE TABLE MINION +( + ID IDENTITY PRIMARY KEY, + NAME VARCHAR(255), + EVIL_MASTER BIGINT +); diff --git a/jdbc/howto/multiple-datasources/src/main/resources/ds2-data.sql b/jdbc/howto/multiple-datasources/src/main/resources/ds2-data.sql new file mode 100644 index 000000000..0727a8688 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/resources/ds2-data.sql @@ -0,0 +1,2 @@ + +INSERT INTO PERSON (NAME) VALUES ('Gru'); \ No newline at end of file diff --git a/jdbc/howto/multiple-datasources/src/main/resources/ds2-schema.sql b/jdbc/howto/multiple-datasources/src/main/resources/ds2-schema.sql new file mode 100644 index 000000000..b0fda71f1 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/resources/ds2-schema.sql @@ -0,0 +1,6 @@ + +CREATE TABLE PERSON +( + ID IDENTITY PRIMARY KEY, + NAME VARCHAR(255) +); diff --git a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java new file mode 100644 index 000000000..60333095b --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java @@ -0,0 +1,35 @@ +package example.springdata.jdbc.howto.multipledatasources; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +@SpringBootTest +public class EvilEmpireTests { + + @Autowired + EvilEmpire subject; + + @Test + void testMinionsForEvilMaster() { + + var actual = this.subject.getMinionsByEvilMaster( 1L ); + + assertThat( actual ) + .hasSize( 5 ) + .containsExactlyInAnyOrder( "Stuart", "Kevin", "Bob", "Donnie", "Ken" ); + + } + + @Test + void testVerfifyIllegalArgumentExceptionThrownWhenEvilMasterNotFound() { + + assertThatThrownBy( () -> this.subject.getMinionsByEvilMaster( 2L ) ) + .isInstanceOf( IllegalArgumentException.class ); + + } + +} diff --git a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java new file mode 100644 index 000000000..ce315320f --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java @@ -0,0 +1,18 @@ +package example.springdata.jdbc.howto.multipledatasources; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class MultipleDataSourceApplicationTests { + + /** + * Sanity Check - Verify configuration for multiple DataSources and + * Spring Data JDBC Repositories are handled correctly + */ + @Test + public void contextLoads() { + + } + +} diff --git a/jdbc/howto/pom.xml b/jdbc/howto/pom.xml index 0ac931b31..7e161a678 100644 --- a/jdbc/howto/pom.xml +++ b/jdbc/howto/pom.xml @@ -25,6 +25,7 @@ idgeneration selectiveupdate schema-generation + multiple-datasources diff --git a/pom.xml b/pom.xml index 104695f61..2ab95b3fe 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 3.5.0-RC1 + 3.5.0 From 2c4ece9fee5827d0391ce0a00a94ba50aab55824 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Fri, 1 Aug 2025 12:17:53 -0400 Subject: [PATCH 2/3] add licence and author attribution Signed-off-by: Daniel Frey --- .../howto/multipledatasources/EvilEmpire.java | 20 ++++++++++++++ .../MultipleDataSourceApplication.java | 18 +++++++++++++ .../DataSourceConfiguration.java | 26 +++++++++++++++++++ .../configuration/JdbcConfiguration.java | 23 ++++++++++++++++ .../multipledatasources/minion/Minion.java | 11 +++++++- .../minion/MinionRepository.java | 6 ++++- .../multipledatasources/person/Person.java | 9 ++++++- .../person/PersonRepository.java | 5 +++- .../multipledatasources/EvilEmpireTests.java | 18 +++++++++++++ .../MultipleDataSourceApplicationTests.java | 18 +++++++++++++ 10 files changed, 150 insertions(+), 4 deletions(-) diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java index 8ddd276e4..c7cba6323 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java @@ -1,3 +1,18 @@ +/* + * Copyright 2013-2025 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 example.springdata.jdbc.howto.multipledatasources; import example.springdata.jdbc.howto.multipledatasources.minion.Minion; @@ -7,6 +22,11 @@ import java.util.List; +/** + * Sample `Service` that uses both Spring Data JDBC Repositories + * + * @author Daniel Frey + */ @Component public class EvilEmpire { diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java index 437d88e7c..80ec21d8d 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java @@ -1,8 +1,26 @@ +/* + * Copyright 2013-2025 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 example.springdata.jdbc.howto.multipledatasources; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * @author Daniel Frey + */ @SpringBootApplication class MultipleDataSourceApplication { diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java index a6d280679..af9a346bd 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java @@ -1,3 +1,18 @@ +/* + * Copyright 2013-2025 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 example.springdata.jdbc.howto.multipledatasources.configuration; import org.springframework.beans.factory.annotation.Qualifier; @@ -27,6 +42,17 @@ import javax.sql.DataSource; import java.util.Optional; +/** + * Multiple DataSource Configuration + * + * Sets up DataSource, NamedParameterJdbcOperations, and TransactionManager + * for each Spring Data JDBC Repository. + * + * The second configuration also sets up the required components for Spring Data JDBC without using explicit + * AutoConfiguration. + * + * @author Daniel Frey + */ @Configuration public class DataSourceConfiguration { diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java index a53c4e44d..a13d3191d 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java @@ -1,8 +1,31 @@ +/* + * Copyright 2013-2025 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 example.springdata.jdbc.howto.multipledatasources.configuration; import org.springframework.context.annotation.Configuration; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; +/** + * Configures the Spring Data JDBC Repositories with explicit callouts to `jdbcOperationsRef` + * and `transactionManagerRef` + * + * @see DataSourceConfiguration.java + * + * @author Daniel Frey + */ @Configuration public class JdbcConfiguration { diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java index eb3229657..8f8319cf5 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2013-2025 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. @@ -13,10 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package example.springdata.jdbc.howto.multipledatasources.minion; import org.springframework.data.annotation.Id; +/** + * + * @param id + * @param name + * @param evilMaster + * + * @author Daniel Frey + */ public record Minion( @Id diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java index a4f3dc2d2..8b6372971 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2013-2025 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package example.springdata.jdbc.howto.multipledatasources.minion; import org.springframework.data.jdbc.repository.query.Query; @@ -21,6 +22,9 @@ import java.util.Collection; +/** + * @author Daniel Frey + */ public interface MinionRepository extends CrudRepository { @Query( "SELECT * FROM MINION WHERE EVIL_MASTER = :id" ) diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java index 864a0e053..6a5b366f4 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2013-2025 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. @@ -17,6 +17,13 @@ import org.springframework.data.annotation.Id; +/** + * + * @param id + * @param name + * + * @author Daniel Frey + */ public record Person( @Id diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java index 301457926..0c6f26c09 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2013-2025 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. @@ -17,6 +17,9 @@ import org.springframework.data.repository.CrudRepository; +/** + * @author Daniel Frey + */ public interface PersonRepository extends CrudRepository { } diff --git a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java index 60333095b..b88caca89 100644 --- a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java @@ -1,3 +1,18 @@ +/* + * Copyright 2013-2025 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 example.springdata.jdbc.howto.multipledatasources; import org.junit.jupiter.api.Test; @@ -7,6 +22,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +/** + * @author Daniel Frey + */ @SpringBootTest public class EvilEmpireTests { diff --git a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java index ce315320f..0c1998d01 100644 --- a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java @@ -1,8 +1,26 @@ +/* + * Copyright 2013-2025 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 example.springdata.jdbc.howto.multipledatasources; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +/** + * @author Daniel Frey + */ @SpringBootTest public class MultipleDataSourceApplicationTests { From a40fefe694ae6e0da7b8c2acc6d173fb6725ffcf Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Fri, 1 Aug 2025 12:19:10 -0400 Subject: [PATCH 3/3] fix license year Signed-off-by: Daniel Frey --- .../springdata/jdbc/howto/multipledatasources/EvilEmpire.java | 2 +- .../multipledatasources/MultipleDataSourceApplication.java | 2 +- .../configuration/DataSourceConfiguration.java | 2 +- .../multipledatasources/configuration/JdbcConfiguration.java | 2 +- .../jdbc/howto/multipledatasources/minion/Minion.java | 2 +- .../jdbc/howto/multipledatasources/minion/MinionRepository.java | 2 +- .../jdbc/howto/multipledatasources/person/Person.java | 2 +- .../jdbc/howto/multipledatasources/person/PersonRepository.java | 2 +- .../jdbc/howto/multipledatasources/EvilEmpireTests.java | 2 +- .../multipledatasources/MultipleDataSourceApplicationTests.java | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java index c7cba6323..de3df8c51 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java index 80ec21d8d..e187777ae 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java index af9a346bd..eb132205d 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java index a13d3191d..b77f4b051 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java index 8f8319cf5..6ce5e45cb 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java index 8b6372971..9cc8e272e 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java index 6a5b366f4..2426235b0 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java index 0c6f26c09..0bbb53022 100644 --- a/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java index b88caca89..26806d7b8 100644 --- a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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. diff --git a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java index 0c1998d01..0d2b10a43 100644 --- a/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2025 the original author or authors. + * Copyright 2025 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.