Files
Glenn Renfro 23fb884e45 Updated code to support using WritableResource
resolves #842

Tests were temporarily commented out til Batch 4111 is resolved
2022-05-11 16:57:07 -04:00
..
2019-03-11 12:48:37 -05:00
2019-03-11 12:48:37 -05:00

= Multiple DataSources Sample Task

This is a Spring Boot application that utilizes two DataSources and explicitly configures
which one to be used for the Spring Cloud Task repository.

== Requirements:

* Java 17 or Above

== Classes:

* `MultipleDataSourcesApplication` - the Spring Boot Main Application.
* `SampleCommandLineRunner` - the `CommandLineRunner` implementation for this task.  It outputs the number of `DataSource` beans found in the context (should be 2).
* `EmbeddedDataSourceConfiguration` - Configures two `DataSource` beans using embedded databases.
* `ExternalDataSourceConfiguration` - Configures two `DataSource` beans using external databases.

* `CustomTaskConfigurer` - Uses a Spring `@Qualifier` to specify the correct `DataSource` to use.

== Build:

[source,shell,indent=2]
----
$ mvn clean package
----

== Execute sample using 2 embedded databases (default):

[source,shell,indent=2]
----
$ java -jar target/multiple-datasources-3.0.0.jar
----

== Execute sample using 2 external databases:

Using the `external` profile, users will be able to establish both the default `spring.datasource` data source and a `second.datasource` data source.
For example:
[source,shell,indent=2]
----
export spring_datasource_url=<your db url>
export spring_datasource_username=<your db user name>
export spring_datasource_password=<your db user password>
export spring_datasource_driverClassName=org.mariadb.jdbc.Driver
export second_datasource_url=jdbc:<your db url>
export second_datasource_username=<your db user name>
export second_datasource_password=<your db user password>
export second_datasource_driverClassName=org.mariadb.jdbc.Driver
java -jar target/multiple-datasources-2.3.0-RELEASE.jar --spring.profiles.active=external
----