9

嗨,我是 liquibase 的新手,我在编译后导入现有项目我得到这个构建失败,我无法理解原因和解决方案我试图理解代码但我真的发现问题要做它 。

这是运行后的结果mvn compile

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for org.squashtest.tm:squashtest-csp-distribution:pom:1.2.0.RELEASE
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.core.log4j:jar -> duplicate declaration of version ${project.version} @ line 419, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.core.jetty.start.osgi:jar -> duplicate declaration of version ${project.version} @ line 424, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.core.service:jar -> duplicate declaration of version ${project.version} @ line 450, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:squashtest-csp-launcher:jar -> duplicate declaration of version ${project.version} @ line 455, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.tm.web:war -> duplicate declaration of version ${project.version} @ line 461, column 17
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.squashtest.csp.tm.service:jar -> duplicate declaration of version ${project.version} @ line 467, column 17
[WARNING] 'profiles.profile[build-mysql].plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.codehaus.mojo:sql-maven-plugin @ line 682, column 15
[WARNING] 'profiles.profile[build-mysql].plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.liquibase:liquibase-maven-plugin @ line 724, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building squashtest-tm-distribution 1.2.0.RELEASE
[INFO] ------------------------------------------------------------------------
[WARNING] Failed to retrieve plugin descriptor for org.codehaus.izpack:izpack-maven-plugin:1.0-alpha-5: Plugin org.codehaus.izpack:izpack-maven-plugin:1.0-alpha-5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.izpack:izpack-maven-plugin:jar:1.0-alpha-5
[INFO] 
[INFO] --- liquibase-maven-plugin:2.0.1:update (default-cli) @ squashtest-csp-distribution ---
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:12.500s
[INFO] Finished at: Fri Jul 13 10:25:08 GMT+01:00 2012
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:2.0.1:update (default-cli) on project squashtest-csp-distribution: The driver has not been specified either as a parameter or in a properties file. -> [Help 1]**
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

这是 pom.xml liquibase 部分:

 <!-- We first run a full install against MySQL -->
  <plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <configuration>
      <skip>${mysql.distro.skip}</skip>
    </configuration>
    <executions>
      <execution>
        <id>generate-mysql-full-install-script</id>
        <phase>process-resources</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>true</dropFirst>
          <changeLogFile>${master.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-full-install-

        version-${project.version}.sql</migrationSqlOutputFile>
        </configuration>
      </execution>
    </executions>
  </plugin>

        <!-- We now run an incremental install against MySQL -->
  <plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <configuration>
      <skip>${mysql.distro.skip}</skip>
    </configuration>
    <executions>
      <execution>
        <id>generate-mysql-0.15.0-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>true</dropFirst>
          <changeLogFile>${upgrade.0.15.0.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
           to-0.15.0.sql</migrationSqlOutputFile>
        </configuration>
      </execution>

      <execution>
        <id>generate-mysql-0.17.0-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>false</dropFirst>
          <changeLogFile>${upgrade.0.17.0.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
           to-0.17.0.sql</migrationSqlOutputFile>
        </configuration>
      </execution>

      <execution>
        <id>generate-mysql-0.20.0-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>false</dropFirst>
          <changeLogFile>${upgrade.0.20.0.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
           to-0.20.0.sql</migrationSqlOutputFile>
        </configuration>
      </execution>

      <execution>
        <id>generate-mysql-0.23.0-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>false</dropFirst>
          <changeLogFile>${upgrade.0.23.0.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
          to-0.23.0.sql</migrationSqlOutputFile>
        </configuration>
      </execution>

      <execution>
        <id>generate-mysql-1.1.0-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>false</dropFirst>
          <changeLogFile>${upgrade.1.1.0.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
           to-1.1.0.sql</migrationSqlOutputFile>
        </configuration>
      </execution>

      <execution>
        <id>generate-mysql-1.1.1-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>false</dropFirst>
          <changeLogFile>${upgrade.1.1.1.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade- 

           to-1.1.1.sql</migrationSqlOutputFile>
        </configuration>
      </execution>
      <execution>
        <id>generate-mysql-1.2.0-script</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>updateSQL</goal>
        </goals>
        <configuration>
          <dropFirst>false</dropFirst>
          <changeLogFile>${upgrade.1.2.0.changelog}</changeLogFile>
          <driver>com.mysql.jdbc.Driver</driver>
          <url>${liquibase.mysql.url}</url>
          <username>${liquibase.mysql.username}</username>
          <password>${liquibase.mysql.password}</password>
          <migrationSqlOutputFile>${database.script.directory}/mysql-upgrade-
          to-${squashTmVersion}.sql</migrationSqlOutputFile>
        </configuration>
      </execution>
    </executions>
   </plugin>
4

3 回答 3

8

您收到此错误是因为 url 的值由 maven 属性提供,称为 ${liquibase.mysql.url}

您可以在 pom 中设置 maven 属性的值,例如:

 <project>
    [...]
    <properties>
      <liquibase.mysql.url>jdbc:mysql://127.0.0.1:3306</liquibase.mysql.url>
      <liquibase.mysql.username>someuser</liquibase.mysql.username>
      [...]
    </properties>
    [...]

liquibase 插件还提供了从属性文件中读取配置属性的可能性,例如 src/main/resources/liquibase.properties 如果选择此选项,则需要通过替换 pom 中的配置部分来配置 liquibase maven 插件,例如:

[...]
 <configuration>
    <propertyFile>src/main/resources/liquibase.properties</propertyFile>
 </configuration>
[...]

然后 liquibase 属性应该看起来像

url=jdbc:mysql://127.0.0.1:3306      
username=someuser
dropFirst=true
changeLogFile=yourfile
[...]

更多信息在这里:http ://www.liquibase.org/documentation/maven/index.html#using_configuration_property_files

于 2013-06-20T18:05:50.527 回答
1

您需要在 .m2/settings.xml 中设置变量 ${liquabase.mysql.url} 等。此处有更多详细信息:缺少 maven .m2 文件夹

您还需要运行 mvn liquibase:update

于 2013-06-20T09:27:41.967 回答
0

首先,您使用的是阶段进程资源,当您想从输出目标目录处理 changeLog 时,以及如果您尝试使用 maven 资源过滤插件在资源文件中使用过滤时,基本上会使用它。

而且我不知道您实际上出于什么目的多次使用 prepare-package 或任何此类阶段,带有 liquibase 的 maven 不是这样设置的,您应该有一个主变更日志,其中应该包括您的其他升级,并带有一些先决条件检查您的每个升级。

如果您想使用您的流程资源阶段,并且打算在资源文件中进行某种过滤,您的目录结构应该如下所示。

src/
`-- main
    |-- java
    `-- resources
        |-- changelog-1.0.0.xml
        |-- changelog-1.1.0.xml
        |-- changelog-install.xml
        |-- com
        |   `-- obolus
        |       `-- database
        |           `-- changelog
        |               |-- v000
        |               |   |-- cst
        |               |   |   |-- entity_extra_data.xml
        |               |   |   `-- entity.xml
        |               |   |-- master.xml
        |               |   `-- tab
        |               |       |-- company.xml
        |               |       |-- entity_extra_data.xml
        |               |       |-- entity.xml
        |               |       `-- anothertable.xml
        |               `-- v001
        |                   |-- master.xml
        |                   `-- tab
        |                       `-- sample.xml
        |-- lib
        |   |-- ojdbc6-11.2.0.3.jar
        `-- liquibase.properties

POM 文件示例

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.obolus</groupId>
    <artifactId>database</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase.maven.plugin}</version>
                <configuration>
                    <changeLogFile>target/classes/changelog-install.xml</changeLogFile
                    <propertyFile>target/classes/liquibase.properties</propertyFile>
                    <logging>${logLevel}</logging>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>status</goal>
                        </goals>
                    </execution>
                </executions>            
            </plugin>
        </plugins>
        <!-- resource filtering -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>${ojdbc.driver.version}</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <ojdbc.driver.version>11.2.0.3</ojdbc.driver.version>
        <liquibase.maven.plugin>3.3.2</liquibase.maven.plugin>
        <logLevel>severe</logLevel>
    </properties>
</project>

希望有帮助。

于 2015-04-30T10:43:40.043 回答