Liquibase ERROR 数据库 URL 未指定为参数或属性文件
Posted
技术标签:
【中文标题】Liquibase ERROR 数据库 URL 未指定为参数或属性文件【英文标题】:Liquibase ERROR The database URL has not been specified either as a parameter or in a properties file 【发布时间】:2021-12-28 14:11:09 【问题描述】:我研究的是 liquibase 工具。 使用教程,我在pom.xml,liquibase.properties中配置了数据,但是出现错误,无法以任何方式解决这个问题。
运行命令 - mvn liquibase:update
我该如何解决这个错误?
堆栈跟踪
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.6.1:update (default-cli) on project crudDataBaseApplication: The database URL has not been specified either as a parameter or in a properties file. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:4.6.1:update (default-cli) on project crudDataBaseApplication: The database URL has not been specified either as a parameter or in a properties file.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
我的 pom 文件
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>4.6.1</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<propertyFile>./src/main/resources/liquibase.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我的 liquibase.properties
changeLogFile=./src/main/resources/master.xml
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/recruitment?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTime
zone=UTC
username=root
password=*********
verbose=true
dropFirst=false
我的dataBaseChangeLogFile master.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet id="dateBaseOperations" author="Dmitry Polischuk">
<sqlFile path="./src/main/resources/tables_creation.sql"/>
</changeSet>
【问题讨论】:
【参考方案1】:看起来路径不正确。而不是写./src/..
,你应该在文件路径中写src/..
。
您还可以尝试使用允许使用环境变量的 Pro 功能。
【讨论】:
尝试了不同的选项没有帮助(以上是关于Liquibase ERROR 数据库 URL 未指定为参数或属性文件的主要内容,如果未能解决你的问题,请参考以下文章
在重新部署 .ear 文件期间未执行 Liquibase 脚本[关闭]
使用 liquibase 在 postgres 中删除索引的问题
Liquibase : $BODY$ 或附近的未终止的美元引号字符串
LiquiBase 问题,类路径资源 [db/changelog/db.changelog-master.yaml] 无法解析为 URL,因为它不存在