2017-04-06 75 views
1

由于某种原因,Liquibase maven插件在我的liquibase.properties文件中设置时未使用我的属性。当我运行mvn liquibase:update时,我得到以下信息。Liquibase maven插件未使用classpath属性

[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无法找到驱动程序,无法连接到数据库。

我看到这个SO问题,但他们使用liquibase可执行文件而不是maven。我用它作为如何使用liquibase.properties文件的例子。

Setting up Liquibase with MS-SQL Server

我看到它是打的异常L571到L588的异常,但实际的异常没有打印出来,所以我不知道这个错误的原因。

https://github.com/liquibase/liquibase/blob/9ae7f90a0bbbbcec229a0788afa74831db348ced/liquibase-maven-plugin/src/main/java/org/liquibase/maven/plugins/AbstractLiquibaseMojo.java#L573

回答

1

,而不是设置在属性文件中的类路径中,你必须把驱动程序jar作为你的Maven POM的依赖。

请参阅documentation for the Liquibase Maven Task,尤其是描述不同JDBC依赖关系的部分。这里有一个片段:

的Maven的Liquibase更新

你需要确保你包括在Maven的POM文件的依赖关系部分的 数据库相关的JDBC驱动程序实例。

MySQL的例子:

<project> 
    <dependencies> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <!-- Replace with the version of the MySQL driver you want to use --> 
      <version>${mysql-version}</version> 
     </dependency> 
    </dependencies> 
</project> 
+1

是啊!这似乎解决了这个问题。我将MSSQL驱动程序添加到我的POM文件依赖项中,并且工作正常。 –