diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index 38d81f99f..6a11a4f02 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -1,7 +1,7 @@ # database init, supports mysql too database=mysql -spring.datasource.url=jdbc:mysql://localhost/petclinic -spring.datasource.username=root -spring.datasource.password=petclinic -# SQL is written to be idempotent so this is safe -spring.datasource.initialization-mode=always +spring.datasource.url=${MYSQL_DB:jdbc:mysql://localhost/petclinic} +spring.datasource.username=${MYSQL_USER:petclinic@petclinicdb2} +spring.datasource.password=${MYSQL_PASS:petclinic} +# Uncomment this the first time the app runs +spring.datasource.initialization-mode=always \ No newline at end of file diff --git a/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt b/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt index 920906687..2afcd64b1 100644 --- a/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt +++ b/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt @@ -23,6 +23,14 @@ 3) Run the app with `spring.profiles.active=mysql` (e.g. as a System property via the command line, but any way that sets that property in a Spring Boot app should work). + +4) For newer versions of Spring Boot, those will fork the JVM that executes the webserver, + which means properties on the command line are lost. You can use: + + mvn spring-boot:run\ + -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=mysql -Dspring.datasource.initialization-mode=always" + + To set profiles & properties. N.B. the "petclinic" database has to exist for the app to work with the JDBC URL value as it is configured by default. This condition is taken care of by the docker-compose