我已经对我的springboot应用程序进行了docker化,现在,我想使用docker-compose连接到postgres映像。
我的docker-compose.yml:
version: "3"
services:
backend:
image: hreview-backend
deploy:
replicas: 2
ports:
- "8080:8080"
volumes:
- /var/lib/springboot/data
db:
image: postgres
restart: always
volumes:
- /var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: root
POSTGRES_DB: hreview
ports:
- "5432:5432"
frontend:
image: hreview-frontend
deploy:
replicas: 1
ports:
- "4200:4200"
然后在我的application.properties中,我拥有:
spring.datasource.url=jdbc:postgresql://db:5432/hreview
spring.datasource.username=root
spring.datasource.password=password
因为我使用ddl-auto:update
,所以休眠应该创建表。
我得到的错误是:
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Unable to execute schema management to JDBC target [create table user (id int4 not null, age int4, email varchar(255), name varchar(255), password varchar(255), role varchar(255), primary key (id))] .....
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "user