-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converting to a single module project
.. modernizing the project .. switching from Derby to Postgres
- Loading branch information
Showing
21 changed files
with
307 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,90 @@ | ||
[](https://github.com/bootique-examples/bootique-jdbc-demo/actions/workflows/verify.yml) | ||
|
||
# bootique-jdbc-demo | ||
|
||
Contains two examples of [bootique-jdbc](https://github.com/bootique/bootique-jdbc) use: | ||
# Bootique 3.x REST Demo | ||
|
||
* [jdbc-app-demo](https://github.com/bootique-examples/bootique-jdbc-demo/tree/master/jdbc-app-demo) - core JDBC API | ||
* [jdbc-test-demo-inmemory-db](https://github.com/bootique-examples/bootique-jdbc-demo/tree/master/jdbc-test-demo-inmemory-db) - JUnit 5 tests using Derby in-memory DB | ||
* TODO: testcontainers demo | ||
This is an example [Bootique](http://bootique.io) JDBC app. It shows how to define and use a named DataSource, | ||
and how to write DB-aware unit tests with Bootique and Testcontainers. | ||
|
||
For the examples working with the older versions of Bootique check the code on the branches: | ||
Different Git branches contain demo code for different versions of Bootique: | ||
|
||
* [1.x](https://github.com/bootique-examples/bootique-jdbc-demo/tree/1.x) | ||
* [3.x](https://github.com/bootique-examples/bootique-jdbc-demo/tree/3.x) | ||
* [2.x](https://github.com/bootique-examples/bootique-jdbc-demo/tree/2.x) | ||
* [1.x](https://github.com/bootique-examples/bootique-jdbc-demo/tree/1.x) | ||
|
||
## Prerequisites | ||
|
||
To build and run the demo, ensure you have the following installed on your machine: | ||
|
||
* Docker | ||
* Java 11 or newer | ||
* Maven | ||
|
||
and then follow these steps: | ||
|
||
## Checkout | ||
``` | ||
git clone git@github.com:bootique-examples/bootique-jdbc-demo.git | ||
cd bootique-jdbc-demo | ||
``` | ||
|
||
## Start Postgres DB Locally | ||
|
||
This starts a Postgres instance listening on port 15432, with login credentials of `postgres` / `test`, and | ||
creates a simple test schema: | ||
|
||
```bash | ||
docker-compose -f docker-compose.yml up -d | ||
``` | ||
|
||
## Build, test and package | ||
|
||
Run the following command to build the code, run the tests and package the app: | ||
``` | ||
mvn clean package | ||
``` | ||
This project uses a [runnable jar with lib folder](https://bootique.io/docs/3.x/bootique-docs/#runnable-jar-with-lib) | ||
packaging recipe, so now the app is packaged for distribution as `target/bootique-jdbc-demo-3.0.tar.gz` archive. But | ||
there is also the "unpacked" version in the `target` folder that can be used to run the app. | ||
|
||
## Run | ||
|
||
The following command prints a help message with supported options: | ||
```bash | ||
java -jar target/bootique-jdbc-demo-3.0.jar | ||
``` | ||
|
||
``` | ||
NAME | ||
bootique-jdbc-demo-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 `--insert` command to create some test data in the DB. DB location and login credential are specified in the | ||
provided `config.yml`. | ||
```bash | ||
java -jar target/bootique-jdbc-demo-3.0.jar -c config.yml -i | ||
``` | ||
|
||
Check the data in the database using the `--select` command: | ||
```bash | ||
java -jar target/jdbc-app-demo-X.XX.jar -c config.yml -s | ||
``` | ||
|
||
Note that per `config.yml` the test database is located under `target/derby/DerbyDatabase`, so running `mvn clean` will | ||
delete it with all the inserted data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 https://maven.apache.org/xsd/assembly-2.0.0.xsd"> | ||
<id>tar.gz</id> | ||
<formats> | ||
<format>tar.gz</format> | ||
</formats> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}</directory> | ||
<useDefaultExcludes>true</useDefaultExcludes> | ||
<outputDirectory>./</outputDirectory> | ||
<includes> | ||
<include>${project.artifactId}-${project.version}.jar</include> | ||
<include>lib/</include> | ||
</includes> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
jdbc: | ||
postgres: | ||
jdbcUrl: jdbc:postgresql://localhost:15432/postgres | ||
username: postgres | ||
password: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3.3' | ||
|
||
services: | ||
postgres: | ||
image: postgres:16.2 | ||
ports: | ||
- "15432:5432" | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: test | ||
volumes: | ||
- ./sql/postgres-schema.sql:/docker-entrypoint-initdb.d/postgres-schema.sql |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
jdbc-app-demo/src/main/java/io/bootique/jdbc/demo/Application.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.