From 454d211a694779efc20a1c36133a053015e21461 Mon Sep 17 00:00:00 2001
From: Vitaliy Fedoriv <vitaliy.fedoriv@gmail.com>
Date: Mon, 13 Mar 2017 22:59:23 +0200
Subject: [PATCH] update documentation

---
 readme.md                                     | 50 ++++++++++---------
 .../resources/application-mysql.properties    |  1 +
 .../application-postgresql.properties         |  1 +
 src/main/resources/application.properties     |  2 +-
 .../db/mysql/petclinic_db_setup_mysql.txt     | 13 ++---
 .../petclinic_db_setup_postgresql.txt         | 20 ++++----
 6 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/readme.md b/readme.md
index e6fb9c7a..43ca93fd 100644
--- a/readme.md
+++ b/readme.md
@@ -10,7 +10,7 @@ The [spring-petclinic-angular2 project](https://github.com/spring-petclinic/spri
 ```
 	git clone https://github.com/spring-petclinic/spring-petclinic-rest.git
 	cd spring-petclinic
-	./mvnw tomcat7:run
+	./mvnw spring-boot:run
 ```
 
 You can then access petclinic here: http://localhost:9966/petclinic/
@@ -31,24 +31,25 @@ Our issue tracker is available here: https://github.com/spring-petclinic/spring-
 In its default configuration, Petclinic uses an in-memory database (HSQLDB) which
 gets populated at startup with data.
 A similar setups is provided for MySql and PostgreSQL in case a persistent database configuration is needed.
-To run petclinic locally using persistent database, it is needed to run with profile defined in main pom.xml file.
-
-For MySQL database, it is needed to run with 'MySQL' profile defined in main pom.xml file.
+To run petclinic locally using persistent database, it is needed to change profile defined in application.properties file.
 
+For MySQL database, it is needed to change param "hsqldb" to "mysql" in string
 ```
-    ./mvnw tomcat7:run -P MySQL
+spring.profiles.active=hsqldb,spring-data-jpa
 ```
+ defined in application.properties file.
 
-Before do this, would be good to check properties defined in MySQL profile inside pom.xml file.
+Before do this, would be good to check properties defined in application-mysql.properties file.
 
 ```
-    <properties>
-        <jpa.database>MYSQL</jpa.database>
-        <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
-        <jdbc.url>jdbc:mysql://localhost:3306/petclinic?useUnicode=true</jdbc.url>
-        <jdbc.username>root</jdbc.username>
-        <jdbc.password>petclinic</jdbc.password>
-    </properties>
+spring.datasource.url = jdbc:mysql://localhost:3306/petclinic?useUnicode=true
+spring.datasource.driverClassName = com.mysql.jdbc.Driver
+spring.datasource.username=root 
+spring.datasource.password=petclinic 
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver 
+spring.jpa.database=MYSQL 
+spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
+spring.jpa.hibernate.ddl-auto=none
 ```      
 
 You may also start a MySql database with docker:
@@ -57,22 +58,23 @@ You may also start a MySql database with docker:
 docker run --name mysql-petclinic -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8
 ```
 
-For PostgreSQL database, it is needed to run with 'PostgreSQL' profile defined in main pom.xml file.
-
+For PostgeSQL database, it is needed to change param "hsqldb" to "postgresql" in string
 ```
-    ./mvnw tomcat7:run -P PostgreSQL
+spring.profiles.active=hsqldb,spring-data-jpa
 ```
+ defined in applcation.properties file.
 
-Before do this, would be good to check properties defined in PostgreSQL profile inside pom.xml file.
+Before do this, would be good to check properties defined in application-postgresql.properties file.
 
 ```
-			<properties>
-                <jpa.database>POSTGRESQL</jpa.database>
-                <jdbc.driverClassName>org.postgresql.Driver</jdbc.driverClassName>
-                <jdbc.url>jdbc:postgresql://localhost:5432/petclinic</jdbc.url>
-                <jdbc.username>postgres</jdbc.username>
-                <jdbc.password>petclinic</jdbc.password>
-            </properties>
+spring.datasource.url=jdbc:postgresql://localhost:5432/petclinic
+spring.datasource.driverClassName=org.postgresql.Driver
+spring.datasource.username=postgres
+spring.datasource.password=petclinic
+spring.datasource.driver-class-name=org.postgresql.Driver
+spring.jpa.database=POSTGRESQL
+spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
+spring.jpa.hibernate.ddl-auto=none
 ```
 You may also start a Postgres database with docker:
 
diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties
index cfadd6ef..c3de1eec 100644
--- a/src/main/resources/application-mysql.properties
+++ b/src/main/resources/application-mysql.properties
@@ -1,4 +1,5 @@
 # uncomment for init database (first start)
+#spring.datasource.initialize=true
 #spring.datasource.schema=classpath*:db/mysql/initDB.sql
 #spring.datasource.data=classpath*:db/mysql/populateDB.sql
 
diff --git a/src/main/resources/application-postgresql.properties b/src/main/resources/application-postgresql.properties
index b9aa1a2e..a5001c67 100644
--- a/src/main/resources/application-postgresql.properties
+++ b/src/main/resources/application-postgresql.properties
@@ -1,4 +1,5 @@
 # uncomment for init database (first start)
+#spring.datasource.initialize=true
 #spring.datasource.schema=classpath*:db/postgresql/initDB.sql
 #spring.datasource.data=classpath*:db/postgresql/populateDB.sql
 
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 4304e983..5458cbee 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -16,7 +16,7 @@
 # When using Spring Data JPA, use: spring-data-jpa
 # ------------------------------------------------
 
-spring.profiles.active=hsqldb,jdbc
+spring.profiles.active=hsqldb,spring-data-jpa
 
 # ------------------------------------------------
 
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 2e430e02..49aa57e7 100644
--- a/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt
+++ b/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt
@@ -12,12 +12,9 @@
    Alternatively, you may use the official MySQL docker image. Refer to the
    README.md for the Docker command line.
 
-2) Dependency for Connector/J, the MySQL JDBC driver (e.g., Connector/J 5.1.x) is
-   included in Petclinic pom.xml file. See the MySQL maven profile.
-   Alternatively, download Connector/J JDBC driver from here:
-   http://dev.mysql.com/downloads/connector/j/
-   and copy the MySQL JDBC driver JAR file (e.g., mysql-connector-java-5.1.5-bin.jar).
 
-3) Change connection parameters into the MySQL profile of the pom.xml.
-   Build and starth the web app with the MySQL profile:
-   ./mvnw tomcat7:run -P MySQL
+2) Create the PetClinic database and user by executing the "db/mysql/initDB.sql"
+and "db/mysql/populateDB.sql" scripts. Or uncomment strings
+#spring.datasource.schema=classpath*:db/mysql/initDB.sql
+#spring.datasource.data=classpath*:db/mysql/populateDB.sql
+ in application-mysql.properties file at the first time you run the app.
\ No newline at end of file
diff --git a/src/main/resources/db/postgresql/petclinic_db_setup_postgresql.txt b/src/main/resources/db/postgresql/petclinic_db_setup_postgresql.txt
index 6d450b7a..e07e1ecc 100644
--- a/src/main/resources/db/postgresql/petclinic_db_setup_postgresql.txt
+++ b/src/main/resources/db/postgresql/petclinic_db_setup_postgresql.txt
@@ -2,21 +2,16 @@
 ===        Spring PetClinic sample application - PostgreSQL Configuration    ===
 ================================================================================
 
-@author Sam Brannen
-@author Costin Leau
+@author Vitaliy Fedoriv
+@autor Antoine Rey
 
 --------------------------------------------------------------------------------
 
 1) Download and install the PostgreSQL database,
    which can be found here: https://www.postgresql.org/download/
 
-2) Dependency for postgresql-driver included in Petclinic pom.xml file.
-   See the PostgreSQL maven profile.
-   Alternatively, download PostgreSQL JDBC driver from here: https://jdbc.postgresql.org/download.html
-   and copy the PostgreSQL JDBC driver JAR file (e.g., postgresql-9.4.1211.jre7.jar) into
-   the db/postgesql directory.
 
-3) Open psql and create the PetClinic database:
+2) Open psql and create the PetClinic database:
  
 	CREATE DATABASE petclinic
   	WITH OWNER = postgres
@@ -24,6 +19,9 @@
        TABLESPACE = pg_default
        CONNECTION LIMIT = -1;
 
-4) If required, change connection parameters into the PostgreSQL profile of the pom.xml.
-   Build and starth the web app with the PostgreSQL profile:
-   ./mvnw tomcat7:run -P PostgreSQL
+3) Create the PetClinic tables by executing the "db/postgresql/initDB.sql".
+Then execute "db/mysql/populateDB.sql" script.
+Or uncomment strings
+#spring.datasource.schema=classpath*:db/postgresql/initDB.sql
+#spring.datasource.data=classpath*:db/postgresql/populateDB.sql
+ in application-postgresql.properties file at the first time you run the app.
\ No newline at end of file
-- 
GitLab