Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56e8e6a

Browse files
Step 1. Migrate from H2 to PostgreSQL
1 parent6b745c7 commit56e8e6a

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

‎existing-spring-boot-app-modification/spring-petclinic-main/build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
runtimeOnly'com.h2database:h2'
3434
developmentOnly'org.springframework.boot:spring-boot-devtools'
3535
testImplementation'org.springframework.boot:spring-boot-starter-test'
36+
runtimeOnly'org.postgresql:postgresql'
3637
}
3738

3839
tasks.named('test') {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
postgres:
3+
image:postgres:16.3
4+
restart:always
5+
ports:
6+
-"5432:5432"
7+
volumes:
8+
-postgres_data:/var/lib/postgresql/data
9+
environment:
10+
POSTGRES_USER:root
11+
POSTGRES_PASSWORD:root
12+
POSTGRES_DB:spring-petclinic
13+
healthcheck:
14+
test:pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB
15+
interval:10s
16+
timeout:5s
17+
start_period:10s
18+
retries:5
19+
volumes:
20+
postgres_data:
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# database init, supports mysql too
2-
database=h2
2+
database=postgres
33
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql
44
spring.sql.init.data-locations=classpath*:db/${database}/data.sql
55
spring.sql.init.mode=always
@@ -8,9 +8,10 @@ spring.sql.init.mode=always
88
spring.thymeleaf.mode=HTML
99

1010
# JPA
11-
spring.jpa.hibernate.ddl-auto=none
11+
spring.jpa.hibernate.ddl-auto=validate
1212
spring.jpa.open-in-view=true
1313

14+
spring.jpa.show-sql=true
1415
# Internationalization
1516
spring.messages.basename=messages/messages
1617

@@ -19,6 +20,10 @@ management.endpoints.web.exposure.include=*
1920

2021
# Logging
2122
logging.level.org.springframework=INFO
22-
23+
#Datasource configuration
24+
spring.datasource.url=jdbc:postgresql://localhost/spring-petclinic
25+
spring.datasource.username=root
26+
spring.datasource.password=root
27+
spring.datasource.driver-class-name=org.postgresql.Driver
2328
# Maximum time static resources should be cached
2429
spring.web.resources.cache.cachecontrol.max-age=12h

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp