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..de3df8c51 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpire.java @@ -0,0 +1,57 @@ +/* + * 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. + * 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; +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; + +/** + * Sample `Service` that uses both Spring Data JDBC Repositories + * + * @author Daniel Frey + */ +@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..e187777ae --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplication.java @@ -0,0 +1,31 @@ +/* + * 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. + * 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 { + + 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..eb132205d --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/DataSourceConfiguration.java @@ -0,0 +1,157 @@ +/* + * 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. + * 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; +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; + +/** + * 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 { + + @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..b77f4b051 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/configuration/JdbcConfiguration.java @@ -0,0 +1,52 @@ +/* + * 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. + * 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 { + + @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..6ce5e45cb --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/Minion.java @@ -0,0 +1,38 @@ +/* + * 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. + * 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; + +/** + * + * @param id + * @param name + * @param evilMaster + * + * @author Daniel Frey + */ +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..9cc8e272e --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/minion/MinionRepository.java @@ -0,0 +1,33 @@ +/* + * 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. + * 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; + +/** + * @author Daniel Frey + */ +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..2426235b0 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/Person.java @@ -0,0 +1,34 @@ +/* + * 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. + * 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; + +/** + * + * @param id + * @param name + * + * @author Daniel Frey + */ +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..0bbb53022 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/main/java/example/springdata/jdbc/howto/multipledatasources/person/PersonRepository.java @@ -0,0 +1,25 @@ +/* + * 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. + * 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; + +/** + * @author Daniel Frey + */ +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..26806d7b8 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/EvilEmpireTests.java @@ -0,0 +1,53 @@ +/* + * 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. + * 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.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; + +/** + * @author Daniel Frey + */ +@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..0d2b10a43 --- /dev/null +++ b/jdbc/howto/multiple-datasources/src/test/java/example/springdata/jdbc/howto/multipledatasources/MultipleDataSourceApplicationTests.java @@ -0,0 +1,36 @@ +/* + * 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. + * 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 { + + /** + * 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