From 1db99dbb58f670ef8e39e9f1edf134b21ce919d6 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 19 May 2022 14:07:16 +0000 Subject: [PATCH] Update to Spring Boot 2.7.0 --- pom.xml | 4 +- .../resources/application-mysql.properties | 2 +- .../resources/application-postgres.properties | 2 +- src/main/resources/application.properties | 4 +- src/main/resources/db/h2/data.sql | 84 +++++++++---------- src/main/resources/db/h2/schema.sql | 12 +-- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/pom.xml b/pom.xml index e1a374328..6831b237a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ 4.0.0 org.springframework.samples spring-petclinic - 2.6.0-SNAPSHOT + 2.7.0-SNAPSHOT org.springframework.boot spring-boot-starter-parent - 2.6.6 + 2.7.0 petclinic diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index d388c9e6d..e23dfa605 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -4,4 +4,4 @@ spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic} spring.datasource.username=${MYSQL_USER:petclinic} spring.datasource.password=${MYSQL_PASS:petclinic} # SQL is written to be idempotent so this is safe -spring.datasource.initialization-mode=always +spring.sql.init.mode=always diff --git a/src/main/resources/application-postgres.properties b/src/main/resources/application-postgres.properties index 80bd3e10a..60889b43c 100644 --- a/src/main/resources/application-postgres.properties +++ b/src/main/resources/application-postgres.properties @@ -3,4 +3,4 @@ spring.datasource.url=${POSTGRES_URL:jdbc:postgresql://localhost/petclinic} spring.datasource.username=${POSTGRES_USER:petclinic} spring.datasource.password=${POSTGRES_PASS:petclinic} # SQL is written to be idempotent so this is safe -spring.datasource.initialization-mode=always +spring.sql.init.mode=always diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 21b629ae8..e96dea25a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,7 @@ # database init, supports mysql too database=h2 -spring.datasource.schema=classpath*:db/${database}/schema.sql -spring.datasource.data=classpath*:db/${database}/data.sql +spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql +spring.sql.init.data-locations=classpath*:db/${database}/data.sql # Web spring.thymeleaf.mode=HTML diff --git a/src/main/resources/db/h2/data.sql b/src/main/resources/db/h2/data.sql index 16dda3e84..f232b1361 100644 --- a/src/main/resources/db/h2/data.sql +++ b/src/main/resources/db/h2/data.sql @@ -1,13 +1,13 @@ -INSERT INTO vets VALUES (1, 'James', 'Carter'); -INSERT INTO vets VALUES (2, 'Helen', 'Leary'); -INSERT INTO vets VALUES (3, 'Linda', 'Douglas'); -INSERT INTO vets VALUES (4, 'Rafael', 'Ortega'); -INSERT INTO vets VALUES (5, 'Henry', 'Stevens'); -INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins'); +INSERT INTO vets VALUES (default, 'James', 'Carter'); +INSERT INTO vets VALUES (default, 'Helen', 'Leary'); +INSERT INTO vets VALUES (default, 'Linda', 'Douglas'); +INSERT INTO vets VALUES (default, 'Rafael', 'Ortega'); +INSERT INTO vets VALUES (default, 'Henry', 'Stevens'); +INSERT INTO vets VALUES (default, 'Sharon', 'Jenkins'); -INSERT INTO specialties VALUES (1, 'radiology'); -INSERT INTO specialties VALUES (2, 'surgery'); -INSERT INTO specialties VALUES (3, 'dentistry'); +INSERT INTO specialties VALUES (default, 'radiology'); +INSERT INTO specialties VALUES (default, 'surgery'); +INSERT INTO specialties VALUES (default, 'dentistry'); INSERT INTO vet_specialties VALUES (2, 1); INSERT INTO vet_specialties VALUES (3, 2); @@ -15,39 +15,39 @@ INSERT INTO vet_specialties VALUES (3, 3); INSERT INTO vet_specialties VALUES (4, 2); INSERT INTO vet_specialties VALUES (5, 1); -INSERT INTO types VALUES (1, 'cat'); -INSERT INTO types VALUES (2, 'dog'); -INSERT INTO types VALUES (3, 'lizard'); -INSERT INTO types VALUES (4, 'snake'); -INSERT INTO types VALUES (5, 'bird'); -INSERT INTO types VALUES (6, 'hamster'); +INSERT INTO types VALUES (default, 'cat'); +INSERT INTO types VALUES (default, 'dog'); +INSERT INTO types VALUES (default, 'lizard'); +INSERT INTO types VALUES (default, 'snake'); +INSERT INTO types VALUES (default, 'bird'); +INSERT INTO types VALUES (default, 'hamster'); -INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); -INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); -INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); -INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); -INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); -INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); -INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); -INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); -INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); -INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); +INSERT INTO owners VALUES (default, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023'); +INSERT INTO owners VALUES (default, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749'); +INSERT INTO owners VALUES (default, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763'); +INSERT INTO owners VALUES (default, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198'); +INSERT INTO owners VALUES (default, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765'); +INSERT INTO owners VALUES (default, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654'); +INSERT INTO owners VALUES (default, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387'); +INSERT INTO owners VALUES (default, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683'); +INSERT INTO owners VALUES (default, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435'); +INSERT INTO owners VALUES (default, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487'); -INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1); -INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2); -INSERT INTO pets VALUES (3, 'Rosy', '2011-04-17', 2, 3); -INSERT INTO pets VALUES (4, 'Jewel', '2010-03-07', 2, 3); -INSERT INTO pets VALUES (5, 'Iggy', '2010-11-30', 3, 4); -INSERT INTO pets VALUES (6, 'George', '2010-01-20', 4, 5); -INSERT INTO pets VALUES (7, 'Samantha', '2012-09-04', 1, 6); -INSERT INTO pets VALUES (8, 'Max', '2012-09-04', 1, 6); -INSERT INTO pets VALUES (9, 'Lucky', '2011-08-06', 5, 7); -INSERT INTO pets VALUES (10, 'Mulligan', '2007-02-24', 2, 8); -INSERT INTO pets VALUES (11, 'Freddy', '2010-03-09', 5, 9); -INSERT INTO pets VALUES (12, 'Lucky', '2010-06-24', 2, 10); -INSERT INTO pets VALUES (13, 'Sly', '2012-06-08', 1, 10); +INSERT INTO pets VALUES (default, 'Leo', '2010-09-07', 1, 1); +INSERT INTO pets VALUES (default, 'Basil', '2012-08-06', 6, 2); +INSERT INTO pets VALUES (default, 'Rosy', '2011-04-17', 2, 3); +INSERT INTO pets VALUES (default, 'Jewel', '2010-03-07', 2, 3); +INSERT INTO pets VALUES (default, 'Iggy', '2010-11-30', 3, 4); +INSERT INTO pets VALUES (default, 'George', '2010-01-20', 4, 5); +INSERT INTO pets VALUES (default, 'Samantha', '2012-09-04', 1, 6); +INSERT INTO pets VALUES (default, 'Max', '2012-09-04', 1, 6); +INSERT INTO pets VALUES (default, 'Lucky', '2011-08-06', 5, 7); +INSERT INTO pets VALUES (default, 'Mulligan', '2007-02-24', 2, 8); +INSERT INTO pets VALUES (default, 'Freddy', '2010-03-09', 5, 9); +INSERT INTO pets VALUES (default, 'Lucky', '2010-06-24', 2, 10); +INSERT INTO pets VALUES (default, 'Sly', '2012-06-08', 1, 10); -INSERT INTO visits VALUES (1, 7, '2013-01-01', 'rabies shot'); -INSERT INTO visits VALUES (2, 8, '2013-01-02', 'rabies shot'); -INSERT INTO visits VALUES (3, 8, '2013-01-03', 'neutered'); -INSERT INTO visits VALUES (4, 7, '2013-01-04', 'spayed'); +INSERT INTO visits VALUES (default, 7, '2013-01-01', 'rabies shot'); +INSERT INTO visits VALUES (default, 8, '2013-01-02', 'rabies shot'); +INSERT INTO visits VALUES (default, 8, '2013-01-03', 'neutered'); +INSERT INTO visits VALUES (default, 7, '2013-01-04', 'spayed'); diff --git a/src/main/resources/db/h2/schema.sql b/src/main/resources/db/h2/schema.sql index 5d6760a4b..4a6c322cb 100644 --- a/src/main/resources/db/h2/schema.sql +++ b/src/main/resources/db/h2/schema.sql @@ -8,14 +8,14 @@ DROP TABLE owners IF EXISTS; CREATE TABLE vets ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, first_name VARCHAR(30), last_name VARCHAR(30) ); CREATE INDEX vets_last_name ON vets (last_name); CREATE TABLE specialties ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(80) ); CREATE INDEX specialties_name ON specialties (name); @@ -28,13 +28,13 @@ ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY ( ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id); CREATE TABLE types ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(80) ); CREATE INDEX types_name ON types (name); CREATE TABLE owners ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, first_name VARCHAR(30), last_name VARCHAR_IGNORECASE(30), address VARCHAR(255), @@ -44,7 +44,7 @@ CREATE TABLE owners ( CREATE INDEX owners_last_name ON owners (last_name); CREATE TABLE pets ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30), birth_date DATE, type_id INTEGER NOT NULL, @@ -55,7 +55,7 @@ ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES t CREATE INDEX pets_name ON pets (name); CREATE TABLE visits ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, pet_id INTEGER, visit_date DATE, description VARCHAR(255)