错误:尝试执行回滚时,未将数据库URL既未指定为参数也未指定为属性文件 [英] Error: The database URL has not been specified either as a parameter or in a properties file when trying to perform a rollback

查看:111
本文介绍了错误:尝试执行回滚时,未将数据库URL既未指定为参数也未指定为属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行回滚,但是出现以下错误

I am trying to perform a rollback but I am getting the following error

The database URL has not been specified either as a parameter or in a properties file.´

我的pom文件中确实有数据库URL,如下所示,所以我认为这不是问题

I do have the database URL in my pom file as you can see below ,so I don't think that's the problem

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.petapilot</groupId>
    <artifactId>migrations</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Migrations</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>15</java.version>
        <liquibase.mysql.url>jdbc:mysql://127.0.0.1:3306</liquibase.mysql.url>
        <liquibase.mysql.username>root</liquibase.mysql.username>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>4.3.1</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

数据库有一个密码.我也必须写吗?我该如何解决?

The database has a password . Do I have to write it too? How can I fix this?

推荐答案

我不确定通过pom.xml文件配置Liquibase的方式.我认为您可以这样尝试:

I'm not sure about the way of configuring Liquibase through pom.xml file. I think you could try this way:

  • 不是在pom.xml的标记内提供所有数据库属性,而是创建"liquibase.properties".并在此文件中填充与liquibase(DB)有关的各种属性.对于创建"liquibase.properties"的帮助,文件,请访问此链接

尝试在现有pom.xml文件中使用与以下类似的配置:

Try using configuration similar to below in your existing pom.xml file:


    <modelVersion>4.0.0</modelVersion>
        <groupId>com.my-group.app</groupId>
        <artifactId>Liqui<SampleDb>-app</artifactId>
        <version>1.0-SNAPSHOT</version>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.liquibase</groupId>
                        <artifactId>liquibase-maven-plugin</artifactId>
                        <version>3.9.0</version>
                        <configuration>
                            <propertyFile>liquibase.properties</propertyFile>
                        </configuration>
                        <dependencies>
                          <dependency>
                              <groupId><db_type></groupId>
                              <artifactId><db_type></artifactId>
                          </dependency>
                      </dependencies>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>

  • 您还可以通过更正现有的pom文件来尝试以下方法.此链接表示要在<配置> 部分.可以尝试围绕< configuration> 部分中的POM文件中的liquibase属性,如下所示:
    • You could also try the following way by correcting your existing pom file. This link says to include liquibase attributes inside <configuration> section. May be try surrounding the liquibase attributes in your POM file in <configuration> section as below:
    • <configuration>
          <changeLogFile>changelog.xml</changeLogFile>
          <url>MyJDBCConnection</url>
          <username>dbuser</username>
          <password>dbpassword</password>
      </configuration>
      

      是的,需要配置DB密码

      干杯!

      这篇关于错误:尝试执行回滚时,未将数据库URL既未指定为参数也未指定为属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆