This is an example Bootique JDBC app. It shows how to define and use a named DataSource, and how to write DB-aware unit tests with Bootique and Testcontainers.
Different Git branches contain example code for different versions of Bootique:
To build and run the project, ensure you have the following installed on your machine:
- Docker
- Java 11 or newer
- Maven
and then follow these steps:
git clone git@github.com:bootique-examples/bootique-jdbc-examples.git
cd bootique-jdbc-examples
This starts a Postgres instance listening on port 15432, with login credentials of postgres
/ test
, and
creates a simple test schema:
docker-compose -f docker-compose.yml up -d
Run the following command to build the code, run the tests and package the app:
mvn clean package
The following command prints a help message with supported options:
java -jar target/bootique-jdbc-examples-3.0.jar
NAME
bootique-jdbc-examples-3.0.jar
OPTIONS
-c yaml_location, --config=yaml_location
Specifies YAML config location, which can be a file path or a URL.
-h, --help
Prints this message.
-H, --help-config
Prints information about application modules and their configuration options.
-i, --insert
Inserts sample data to a DB
-s, --select
Selects data from a DB
Run the -i
(or --insert
) command to create some sample data in the DB. DB location and login credential are
specified in the provided config.yml
.
java -jar target/bootique-jdbc-examples-3.0.jar -c config.yml -i
Run the -s
(or --select
) command to display the data inserted in the previous step:
java -jar target/bootique-jdbc-examples-3.0.jar -c config.yml -s