Java Liquibase maven插件未使用类路径属性
出于某种原因,当我在Java Liquibase maven插件未使用类路径属性,java,maven,liquibase,Java,Maven,Liquibase,出于某种原因,当我在Liquibase.properties文件中设置我的属性时,Liquibase maven插件没有使用我的属性。当我运行mvn liquibase:update时,我得到以下信息 [INFO] there are no resolved artifacts for the Maven project. [INFO] Parsing Liquibase Properties File [INFO] File: target/classes/liquibase.proper
Liquibase.properties
文件中设置我的属性时,Liquibase maven插件没有使用我的属性。当我运行mvn liquibase:update
时,我得到以下信息
[INFO] there are no resolved artifacts for the Maven project.
[INFO] Parsing Liquibase Properties File
[INFO] File: target/classes/liquibase.properties
[INFO] 'classpath' in properties file is not being used by this task.
因此,更新失败,因为liquibase找不到驱动程序,也无法连接到数据库
我看到了这个问题,但他们使用的是liquibase可执行文件,而不是maven。我用它作为如何使用liquibase.properties文件的示例
我看到它在哪里遇到异常L571到L588异常,但实际的异常没有打印出来,所以我不知道错误的原因
与在属性文件中设置类路径不同,您必须将驱动程序jar作为依赖项放在maven POM中 请参阅,特别是描述不同JDBC依赖关系的部分。下面是一个片段: Maven Liquibase更新示例 您需要确保为您的应用程序包含相关的JDBC驱动程序 Maven POM文件的依赖项部分中的数据库 MySQL示例:
mysql
mysql连接器java
${mysql版本}
就我而言,这只是一个简单的复制粘贴问题
liquibase.properties
中的属性driver
以空格结尾。删除空间后,一切正常
driver:com.mysql.cj.jdbc.driver
vs
driver:com.mysql.cj.jdbc.driver
这让我找到了正确的方向。在我的例子中,我需要声明Maven资源
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
src/main/resources
真的
希望有帮助 是的!这似乎解决了问题。我将MSSQL驱动程序添加到我的POM文件依赖项中,它成功了。
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>