= 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]
----
mvn clean package
----

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

[source,shell]
----
java -jar target/multiple-datasources-3.0.0.jar
----

== Native Build:

[source,shell]
----
mvn -Pnative native:compile
----

== RUn sample using 2 embedded databases (default) with native app:

[source,shell]
----
./target/multiple-datasources
----

== 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
----
