SQL Server驱动程序以在Maven中使用liquibase [英] sql server driver to work with liquibase in maven

查看:88
本文介绍了SQL Server驱动程序以在Maven中使用liquibase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使liquibase-maven-plugin与MS Sql Server配合使用时遇到问题.我已将最新的sqljdbc4.jar添加到我的本地Maven存储库中,并且通过运行liquibase.bat从现有数据库中生成了一个变更集.当我尝试运行

I´m having a problem getting the liquibase-maven-plugin to work with MS Sql Server. I have added the lastest sqljdbc4.jar to my local maven repo and I have generated a changeset from my existing database by running the liquibase.bat. When i try to run

mvn liquibase:update

我收到以下异常

Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.5:update (default-cli) on project parent: The driver has not been specified either as a parameter or in a properties file.

这是我当前的pom.xml

This is my current pom.xml

<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>se.myproject</groupId>
  <artifactId>parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>parent</name>

  <properties>
        <junit.version>4.4</junit.version>
        <jdk.version>1.7</jdk.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <glassfish.glassfishDirectory>/glassfish/glassfish/</glassfish.glassfishDirectory>
                <glassfish.user>myuser</glassfish.user>
                <glassfish.adminPassword>mypass</glassfish.adminPassword>
                <glassfish.domain.name>domain1</glassfish.domain.name>
                <glassfish.domain.host>localhost</glassfish.domain.host>
                <glassfish.domain.adminPort>4848</glassfish.domain.adminPort>
    </properties>


<modules>
    <module>commons</module>
    <module>entities</module>
    <module>services</module>
    <module>web</module>
</modules>


  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    <dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.9.5</version>
    </dependency>
    <dependency>
      <groupId>com.microsoft.sqlserver</groupId>
      <artifactId>sqljdbc4</artifactId>
      <version>4.0</version>
    </dependency>

    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-maven-plugin</artifactId>
        <version>2.0.5</version>
    </dependency>

  </dependencies>


  <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>${jdk.version}</source>
                        <target>${jdk.version}</target>
                        <outputDirectory>target</outputDirectory>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <version>2.0.5</version>
                    <executions>
                        <execution>
                            <phase>process-resources</phase>
                            <configuration>
                                <changeLogFile>changelog-${project.version}.xml</changeLogFile>
                                <driver>com.microsoft.sqlserver.sqljdbc4</driver>
                                <url>jdbc:sqlserver://localhost:1433;databaseName=MyDb</url>
                                <username>myusername</username>
                                <password>mypassword</password>
                            </configuration>
                            <goals>
                                <goal>update</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </pluginManagement>


  </build>

</project>

推荐答案

您需要将liquibase数据库凭据指定为属性,例如:

You need to specify the liquibase database credentials as properties, for example:

<properties>
    <liquibase.url>jdbc:h2:target/db1/liquibaseTest;AUTO_SERVER=TRUE</liquibase.url>
    <liquibase.driver>org.h2.Driver</liquibase.driver>
    <liquibase.username>user</liquibase.username>
    <liquibase.password>pass</liquibase.password>
</properties>

请参见以下示例:

这篇关于SQL Server驱动程序以在Maven中使用liquibase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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