liquibase-hibernate5不能与liquibase-maven-plugin一起使用

时间:2016-12-31 15:07:57

标签: spring hibernate spring-boot liquibase liquibase-hibernate

我正在使用Spring Boot Starter 1.4.2.RELEASE + Hibernate 5 + Hibernate Spatial + Liquibase 3.5.3 + Liquibase Hibernate 5(liquibase-hibernate5 3.6)+ PostgreSQL我无法使用liquibase:diff目标

这是我的设置:

let preparedOMassChangeOb = oMassChangeOb
    .do(function (aMassDates) {
      const oModel = self.getModel("vmCalSpecialDates");
      oModel.setProperty("/aActualDates", aMassDates);
    })
    .catch(..some error-handler-logic...);

let preparedOSaveCancelFooterStateOb = oSaveCancelFooterStateOb
    .do((oBtnState) => {
      const oModel = self.getModel("vmButtonsState");
      oModel.setProperty("/bSave", oBtnState.bSave);
      oModel.setProperty("/bCancel", oBtnState.bCancel)
    });

Rx.Observable.merge(
    preparedOMassChangeOb,
    preparedOSaveCancelFooterStateOb
).subscribe();

运行mvn clean compile liquibase:diff -X给出了以下异常:

      <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <dependencies>
                <dependency>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                    <version>1.1.0.Final</version>
                </dependency>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-spatial</artifactId>
                    <version>${hibernate.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.javassist</groupId>
                    <artifactId>javassist</artifactId>
                    <version>3.18.2-GA</version>
                </dependency>
                <dependency>
                    <groupId>org.liquibase.ext</groupId>
                    <artifactId>liquibase-hibernate5</artifactId>
                    <version>${liquibase-hibernate5.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>${postgresql.driver.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                    <version>${project.parent.version}</version>
                </dependency>
            </dependencies>
            <configuration>
                <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
                <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                <diffExcludeObjects>geography_columns, geometry_columns, raster_columns,
                    raster_overviews, spatial_ref_sys</diffExcludeObjects>
                <driver>org.postgresql.Driver</driver>
                <url>jdbc:postgresql://localhost:5432/mydb?useUnicode=true&amp;characterEncoding=utf8</url>
                <!--<defaultSchemaName></defaultSchemaName>-->
                <username>myusr</username>
                <password>mypwd</password>

                <referenceUrl>hibernate:spring:my.package.with.domain?dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect</referenceUrl>
                <verbose>true</verbose>
                <logging>debug</logging>
            </configuration>
        </plugin>

我真的不明白为什么会这样。我尝试了一切。我正在通过JPA存储库从我的RestControllers进行SQL调用,没有任何问题。我也能够毫无问题地运行其他liquibase maven目标(成功连接到DB)。

如果有人能帮助我,我真的很感激。感谢。

1 个答案:

答案 0 :(得分:1)

我发现您可以添加属性-Djadira.usertype.useJdbc42Apis=false来跳过此错误。请参阅以下代码https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/usertype.spi/src/main/java/org/jadira/usertype/spi/shared/AbstractUserTypeHibernateIntegrator.java#L56

我认为(未经测试)您可以在配置中设置systemProperties

<configuration>
  <systemProperties>
    <property>
      <name>jadira.usertype.useJdbc42Apis</name>
      <value>false</value>
    </property>
  </systemProperties>
</configuration

最好的问候