我已经设置了一个带有3个模块的弹簧启动项目(父级)。
-- parent
--module 1
--module 2
--module 3
现在我想将一个新的maven项目添加为这个父项目的新模块。
新的maven项目正在使用 liquibase-maven-plugin ,并且作为单个项目非常适合。但是当我尝试将新的maven项目集成到父项目时,它就失败了。
Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default)
on project database-migration: Error setting up or running Liquibase:
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException:
Connection could not be created to ${database.url} with driver org.postgresql.Driver.
Possibly the wrong driver for the given database URL
当我将此父节添加到我的新模块项目时,liquibase-maven-plugin无法再替换${database.url}
文件中定义的占位符liquibase.properties
:
<parent>
<artifactId>backend-parent</artifactId>
<groupId>xyz</groupId>
<version>0.1.0-SNAPSHOT</version>
</parent>
父/超POM看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz</groupId>
<artifactId>backend-parent</artifactId>
<packaging>pom</packaging>
<version>0.1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<modules>
<module>api</module>
<module>db</module>
<module>business</module>
<module>migration</module>
</modules>
<properties>
<java.version>9</java.version>
<start-class>xyz.Application</start-class>
<postgresql.version>42.2.1</postgresql.version>
<h2.database.version>1.4.197</h2.database.version>
...
</<properties>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
新模块POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>backend-parent</artifactId>
<groupId>xyz</groupId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>migration</artifactId>
<properties>
<liquibase.maven.plugin.version>3.5.3</liquibase.maven.plugin.version>
<postgresql.version>42.2.1</postgresql.version>
<env>local</env>
</properties>
<profiles>
<profile>
<id>update-db</id>
<build>
<filters>
<filter>${project.basedir}/src/main/resources/filters/${env}/database.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources/liquibase/</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.maven.plugin.version}</version>
<configuration>
<changeLogFile>src/main/resources/liquibase/changelog-master.xml</changeLogFile>
<propertyFile>target/classes/liquibase.properties</propertyFile>
<promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
<driver>org.postgresql.Driver</driver>
<logging>debug</logging>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
liquibase属性
url: ${database.url}
username: ${database.username}
verbose: true
contexts: ${environment}
正如我所说的,没有新模块POM中的父节,工作正常。 我使用这个cmd来构建迁移。
mvn clean install -Pupdate-db -Denv=local
我确实试过这里描述的几个变通方法:
感谢您的任何建议。