From 0c7db646ef89c7435f739f5f7dd4db60505ab8aa Mon Sep 17 00:00:00 2001 From: Dave Syer <dsyer@pivotal.io> Date: Mon, 5 Dec 2016 21:50:29 +0000 Subject: [PATCH] Make mysql configuration more first class --- docker-compose.yml | 9 +++++++++ pom.xml | 5 +++++ src/main/resources/application-mysql.properties | 7 +++++++ .../resources/db/mysql/petclinic_db_setup_mysql.txt | 12 +++++------- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 docker-compose.yml create mode 100644 src/main/resources/application-mysql.properties diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1631ec9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +mysql: + image: mysql + ports: + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_DATABASE=test + volumes: + - "./conf.d:/etc/mysql/conf.d:ro" \ No newline at end of file diff --git a/pom.xml b/pom.xml index 95a5a71..d306cb9 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,11 @@ <artifactId>hsqldb</artifactId> <scope>runtime</scope> </dependency> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <scope>runtime</scope> + </dependency> <!-- EhCache --> <dependency> diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties new file mode 100644 index 0000000..fd561fa --- /dev/null +++ b/src/main/resources/application-mysql.properties @@ -0,0 +1,7 @@ +# database init, supports mysql too +database=mysql +spring.datasource.url=jdbc:mysql://localhost/test +spring.datasource.username=root +spring.datasource.password=root + # Uncomment this the first time the app runs +# spring.datasource.initialize=true \ 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 6b3014b..6733a93 100644 --- a/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt +++ b/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt @@ -9,11 +9,9 @@ -------------------------------------------------------------------------------- 1) Download and install the MySQL database (e.g., MySQL Community Server 5.1.x), - which can be found here: http://dev.mysql.com/downloads/ + which can be found here: http://dev.mysql.com/downloads/. Or run the + "docker-compose.yml" from the root of the project (if you have docker installed + locally). -2) Add the MySQL JDBC driver to your classpath. - -3) Set "database=mysql" in "application.properties" - -4) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql" - scripts (or set "spring.datasource.initialize=true" the first time you run the app. +2) Create the PetClinic database and user by executing the "db/mysql/{schema,data}.sql" + scripts (or set "spring.datasource.initialize=true" the first time you run the app). -- GitLab