Postgresql Docker中未执行Liquibase的Spring引导
我是Docker的新手,我一直在尝试实现数据库的容器化(Postgresql)和API(Spring Boot with liquibase)。然而,似乎liquibase没有运行。请参考以下内容。提前谢谢 应用程序。属性:Postgresql Docker中未执行Liquibase的Spring引导,postgresql,spring-boot,docker,liquibase,Postgresql,Spring Boot,Docker,Liquibase,我是Docker的新手,我一直在尝试实现数据库的容器化(Postgresql)和API(Spring Boot with liquibase)。然而,似乎liquibase没有运行。请参考以下内容。提前谢谢 应用程序。属性: spring.datasource.url=jdbc:postgresql://db:5432/demo spring.datasource.username=compose-postgres spring.datasource.password=compose-postg
spring.datasource.url=jdbc:postgresql://db:5432/demo
spring.datasource.username=compose-postgres
spring.datasource.password=compose-postgres
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/liquibase-changelog.xml
version: '2'
services:
api:
image: 'docker-spring-boot-postgres:latest'
build:
context: .
container_name: api
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/demo
- SPRING_DATASOURCE_USERNAME=compose-postgres
- SPRING_DATASOURCE_PASSWORD=compose-postgres
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
ports:
- "8080:8080"
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=compose-postgres
- POSTGRES_PASSWORD=compose-postgres
- POSTGRES_DB=demo
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="https://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="changelog/01-createTableUser-changelog.sql" relativeToChangelogFile="true"/>
<!-- more <include> tags go here -->
</databaseChangeLog>
docker-compose build
docker-compose up
docker compose.yml:
spring.datasource.url=jdbc:postgresql://db:5432/demo
spring.datasource.username=compose-postgres
spring.datasource.password=compose-postgres
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/liquibase-changelog.xml
version: '2'
services:
api:
image: 'docker-spring-boot-postgres:latest'
build:
context: .
container_name: api
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/demo
- SPRING_DATASOURCE_USERNAME=compose-postgres
- SPRING_DATASOURCE_PASSWORD=compose-postgres
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
ports:
- "8080:8080"
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=compose-postgres
- POSTGRES_PASSWORD=compose-postgres
- POSTGRES_DB=demo
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="https://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="changelog/01-createTableUser-changelog.sql" relativeToChangelogFile="true"/>
<!-- more <include> tags go here -->
</databaseChangeLog>
docker-compose build
docker-compose up
Dockerfile:
spring.datasource.url=jdbc:postgresql://db:5432/demo
spring.datasource.username=compose-postgres
spring.datasource.password=compose-postgres
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/liquibase-changelog.xml
version: '2'
services:
api:
image: 'docker-spring-boot-postgres:latest'
build:
context: .
container_name: api
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/demo
- SPRING_DATASOURCE_USERNAME=compose-postgres
- SPRING_DATASOURCE_PASSWORD=compose-postgres
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
ports:
- "8080:8080"
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=compose-postgres
- POSTGRES_PASSWORD=compose-postgres
- POSTGRES_DB=demo
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="https://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="changelog/01-createTableUser-changelog.sql" relativeToChangelogFile="true"/>
<!-- more <include> tags go here -->
</databaseChangeLog>
docker-compose build
docker-compose up
liquibase changelog.xml:
spring.datasource.url=jdbc:postgresql://db:5432/demo
spring.datasource.username=compose-postgres
spring.datasource.password=compose-postgres
spring.jpa.hibernate.ddl-auto=none
spring.liquibase.change-log=classpath:db/liquibase-changelog.xml
version: '2'
services:
api:
image: 'docker-spring-boot-postgres:latest'
build:
context: .
container_name: api
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/demo
- SPRING_DATASOURCE_USERNAME=compose-postgres
- SPRING_DATASOURCE_PASSWORD=compose-postgres
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
ports:
- "8080:8080"
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=compose-postgres
- POSTGRES_PASSWORD=compose-postgres
- POSTGRES_DB=demo
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="https://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.liquibase.org/xml/ns/dbchangelog
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="changelog/01-createTableUser-changelog.sql" relativeToChangelogFile="true"/>
<!-- more <include> tags go here -->
</databaseChangeLog>
docker-compose build
docker-compose up
我看到您提供了所有配置。您还可以提供您的接收错误以及您使用的liquibase命令吗?我们可以看到错误吗?我只看到配置(感谢提供详细的文档),但没有看到错误。