我正试图在一个Spring Boot应用程序中使用Liquibase和Hibernate生成一个diff-File,其中包含我正在使用的数据库和我的JPA实体之间的更改。我遵循本教程:https://www.baeldung.com/liquibase-refactor-schema-of-java-app(特别是步骤7)。
但是,在执行MVN LILEATE:DIFF命令时,我只收到以下错误:
liquibase.exception.DatabaseException: java.lang.RuntimeException: Driver class was not specified and could not be determined from the url (hibernate:spring:com.example.demo?dialect=org.hibernate.dialect.PostgreSQLDialect& hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy& hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy)
我已经在互联网上搜索过,有些人也有类似的问题,但他们的解决方案在我的情况下不起作用。
以下是我的liblate.properties文件:
url = jdbc:postgresql://localhost:5432/employeediff
username = myuser
password =
driver=org.postgresql.Driver
classpath=/usr/local/opt/liquibase/internal/lib/postgresql.jar
changeLogFile = src/main/resources/db/changelog/changelog-master.xml
diffChangeLogFile = src/main/resources/db/changelog/diffchangelog.xml
referenceUrl= hibernate:spring:com.example.demo?dialect=org.hibernate.dialect.PostgreSQLDialect
这是我的pom.xml文件:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.liquibase/liquibase-maven-plugin -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<!-- <scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.1.0</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.22</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.7.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
任何帮助都是非常感谢的!非常感谢!
亲切的问候
1条答案
按热度按时间ehxuflar1#
我在另一个网站上找到了这个解决方案,但它有可怕的弹出窗口,所以除非你真的想要,否则我就不给你链接了:
问题出在我的
referenceUrl
中。属性使用包扫描时,referenceUrl
是liquibase-hibernate
,因此url必须以hibernate:spring:
开头我变了
vt.进入,进入
这解决了我的问题。