diff --git a/build.gradle b/build.gradle index 936ff1edb..8113feb9b 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,10 @@ ext.webjarsFontawesomeVersion = "4.7.0" ext.webjarsBootstrapVersion = "5.3.8" dependencies { + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'com.h2database:h2' + implementation 'org.liquibase:liquibase-core' + implementation 'org.springframework.boot:spring-boot-starter-liquibase' implementation 'org.springframework.boot:spring-boot-starter-cache' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' @@ -72,6 +76,13 @@ checkstyleNohttp { configFile = file('src/checkstyle/nohttp-checkstyle.xml') } +bootRun { + systemProperty "spring.profiles.active", "dev" + // отключаем AOT + dependsOn.removeAll { it.name.startsWith("processAot") } + dependsOn.removeAll { it.name.startsWith("compileAot") } +} + tasks.named("formatMain").configure { dependsOn("checkstyleMain") } tasks.named("formatMain").configure { dependsOn("checkstyleNohttp") } diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 000000000..1fe1cf788 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,12 @@ +spring.liquibase.contexts=dev +spring.liquibase.enabled=true +#spring.liquibase.run-on-startup=true +spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml + +spring.datasource.url=jdbc:h2:file:./data/testdb +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver + +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index e23dfa605..870ba8444 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.sql.init.mode=always +spring.sql.init.mode=never diff --git a/src/main/resources/application-postgres.properties b/src/main/resources/application-postgres.properties index b265d7e5b..39ba0315c 100644 --- a/src/main/resources/application-postgres.properties +++ b/src/main/resources/application-postgres.properties @@ -4,4 +4,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.sql.init.mode=always +spring.sql.init.mode=never diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties new file mode 100644 index 000000000..c79578136 --- /dev/null +++ b/src/main/resources/application-prod.properties @@ -0,0 +1 @@ +spring.liquibase.contexts=prod diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 630c1145a..64099ddcc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,22 @@ # database init, supports mysql too -database=h2 -spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql -spring.sql.init.data-locations=classpath*:db/${database}/data.sql +#database=h2 +#spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql +#spring.sql.init.data-locations=classpath*:db/${database}/data.sql +spring.sql.init.mode=never + +spring.profiles.active=dev + +spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.username=sa +spring.datasource.password= +spring.datasource.driver-class-name=org.h2.Driver + +spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml +spring.liquibase.enabled=true +#spring.liquibase.run-on-startup=true + +logging.level.liquibase=DEBUG +logging.level.org.springframework.boot.autoconfigure.liquibase=DEBUG # Web spring.thymeleaf.mode=HTML diff --git a/src/main/resources/db/changelog/db.changelog-dev-data.xml b/src/main/resources/db/changelog/db.changelog-dev-data.xml new file mode 100644 index 000000000..accd4c2b4 --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-dev-data.xml @@ -0,0 +1,196 @@ + + + + + + + + + SELECT COUNT(*) FROM vets + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM specialties + + + + + + + + + + + + + SELECT COUNT(*) FROM vet_specialties + + + + + + + + + + + + + + + SELECT COUNT(*) FROM types + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM owners + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM pets + + + + + + + + + + + + + + + + + + + + + + + SELECT COUNT(*) FROM visits + + + + + + + + + + diff --git a/src/main/resources/db/changelog/db.changelog-master.xml b/src/main/resources/db/changelog/db.changelog-master.xml new file mode 100644 index 000000000..21dd2b81b --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-master.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/src/main/resources/db/changelog/db.changelog-schema.xml b/src/main/resources/db/changelog/db.changelog-schema.xml new file mode 100644 index 000000000..04e657516 --- /dev/null +++ b/src/main/resources/db/changelog/db.changelog-schema.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +