0

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

I get the following exception

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.

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>
4

1 回答 1

0

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

<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>

请参见以下示例:

于 2013-09-22T23:14:15.473 回答