diff --git a/pom.xml b/pom.xml index cf47f8aa6df..383824385eb 100644 --- a/pom.xml +++ b/pom.xml @@ -220,7 +220,7 @@ spring-boot-maven-plugin - build-info @@ -378,7 +378,7 @@ - org.eclipse.m2e @@ -434,6 +434,30 @@ + + mysql + + mysql,docker-compose + + + + org.springframework.boot + spring-boot-docker-compose + + + + + postgres + + postgres,docker-compose + + + + org.springframework.boot + spring-boot-docker-compose + + + - \ No newline at end of file + diff --git a/readme.md b/readme.md index 79b0fb692ae..ee9817b0ff8 100644 --- a/readme.md +++ b/readme.md @@ -47,7 +47,25 @@ In its default configuration, Petclinic uses an in-memory database (H2) which gets populated at startup with data. The h2 console is exposed at `http://localhost:8080/h2-console`, and it is possible to inspect the content of the database using the `jdbc:h2:mem:` URL. The UUID is printed at startup to the console. -A similar setup is provided for MySQL and PostgreSQL if a persistent database configuration is needed. Note that whenever the database type changes, the app needs to run with a different profile: `spring.profiles.active=mysql` for MySQL or `spring.profiles.active=postgres` for PostgreSQL. +A similar setup is provided for MySQL and PostgreSQL if a persistent database configuration is needed. Two options are available: + +### Enable database via maven profile + +Pass the profile for the corresponding database as an argument: + +```bash +./mvnw spring-boot:run -Pmysql +``` + +or + +```bash +./mvnw spring-boot:run -Ppostgres +``` + +### Manual configuration + +Note that whenever the database type changes, the app needs to run with a different profile: `spring.profiles.active=mysql` for MySQL or `spring.profiles.active=postgres` for PostgreSQL. You can start MySQL or PostgreSQL locally with whatever installer works for your OS or use docker: diff --git a/src/main/resources/application-docker-compose.properties b/src/main/resources/application-docker-compose.properties new file mode 100644 index 00000000000..6b3f6ae190f --- /dev/null +++ b/src/main/resources/application-docker-compose.properties @@ -0,0 +1 @@ +spring.docker.compose.profiles.active=${database}