小编UO *_*Man的帖子

Liquibase 不创建基于 JPA 实体的差异变更日志

我试图在已经提出的问题以及一些用户推荐的这篇文章中找到答案:http : //www.operatornew.com/2012/11/automatic-db-migration-for-java-web.html但没有运气好的话。

问题是我使用 Maven 构建工具和 Postgres DB 为我的 Java 项目完整配置了 Liquibase,但即使我已经定义了 Hibernate 实体,Liquibase diff也没有考虑它们,并且不会基于 JPA 注释实体生成变更锁.

我尝试了所有方法,但使用空的changelock-master.xml并定义了 2 个实体,结果diff.xml为空。

这是我的pom.xml

        <!--LIQUIBASE-->
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.4.1</version>
        </dependency>
        ...
        <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.5.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate4</artifactId>
                        <version>3.6</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-beans</artifactId>
                        <version>4.1.7.RELEASE</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.data</groupId>
                        <artifactId>spring-data-jpa</artifactId>
                        <version>1.7.3.RELEASE</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
                    <changeLogFile>src/main/resources/db/changelog/changelog-master.xml</changeLogFile>
                </configuration>
            </plugin>
Run Code Online (Sandbox Code Playgroud)

在这里,我定义了liquibase.properties

referenceUrl=hibernate:spring:com.victus.applied.entity?dialect=org.hibernate.dialect.PostgreSQLDialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUsername=testusername
referencePassword=
driver=org.postgresql.Driver
url=jdbc:postgresql://localhost:5432/applied
username=testusername …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa liquibase

2
推荐指数
1
解决办法
3194
查看次数

标签 统计

hibernate ×1

java ×1

jpa ×1

liquibase ×1