Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Liquibase ANT Build.xml Oracle驱动程序_Ant_Liquibase - Fatal编程技术网

Liquibase ANT Build.xml Oracle驱动程序

Liquibase ANT Build.xml Oracle驱动程序,ant,liquibase,Ant,Liquibase,我正在尝试运行ant脚本,通过liquibase部署更改 <project name="Example" xmlns:liquibase="antlib:liquibase.integration.ant"> <taskdef resource="liquibase/integration/ant/antlib.xml" uri="antlib:liquibase.integration.ant"> <

我正在尝试运行ant脚本,通过liquibase部署更改

<project name="Example" xmlns:liquibase="antlib:liquibase.integration.ant">

    <taskdef 
        resource="liquibase/integration/ant/antlib.xml" 
        uri="antlib:liquibase.integration.ant">

        <classpath path="C:\liquibase\lib\liquibase\"/>

    </taskdef>

  <property name="db.changelog.file" value="C:\projects\lbdemo\trunk\db_v4.xml"/>
  <property name="database.url" value="jdbc:oracle:thin:@mydb:1521:ORCL"/>
  <property name="database.username" value="myuser"/>
  <property name="database.password" value="mypassword"/>
  <property name="database.driver" value="oracle.jdbc.OracleDriver"/>

  <liquibase:database id="my-database" driver="${database.driver}" url="${database.url}" user="${database.username}" password="${database.password}"/>

  <liquibase:updateDatabase databaseref="my-database" changelogfile="${db.changelog.file}"/>

</project>

安装路径:

  • Liquibase安装在:C:\Liquibase
  • JDBC驱动程序位于:C:\liquibase\ojdbc7.jar

  • Ant安装在:C:\apache-Ant-1.10.1

  • 我将liquibase.jar复制到:C:\apache-ant-1.10.1\lib
  • 我的ANT构建文件:C:\projects\lbdemo\trunk\build.xml
  • 我的更改文件:C:\projects\lbdemo\trunk\db\u v4.xml
测试

  • 我能够使用Windows命令行使用我的更改文件db_v4.xmls成功运行liquibase更新

  • 如果我从ANT build.xml文件中删除所有liquibase标记,我就能够运行它

错误:

运行上述ANT构建时,我遇到以下错误:

C:\projects\lbdemo\trunk>ant

C:\projects\lbdemo\trunk\build.xml[liquibase:updateDatabase]正在启动 液化

生成失败C:\projects\lbdemo\trunk\BUILD.xml:15:找不到类: oracle.jdbc.OracleDriver

总时间:1秒

我怎样才能告诉liquibase在ant中Oracle驱动程序的位置


我提到:

这里是成功运行的ant build.xml。ojdbc驱动程序和liquibase jar都位于C:\liquibase\;我在updateDatabase标记中引用了它:liquibase:updateDatabase classpathref=“driver.classpath”


更简单的方法是将所有必需的(liquibase.jar和ojdbc7.jar)库放在一个目录中,并使用路径id引用它们

<path id="liquibaseClasspath">
    <fileset dir="C:\projects\lbdemo\trunk\lib" includes="*.jar" />
</path>
<target name="Upgrade_db">
    <echo message="Upgrading DataBase" />
    <updateDatabase changeLogFile="C:\projects\lbdemo\trunk\db_v4.xml" driver="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}"  classpathref="liquibaseClasspath" />
</target>


您还可以提到一个文件中的所有目录位置,并将该文件导入ant文件。

对于Liquibase任务(在
taskdef
中),您需要在
classpath
中包含JDBC驱动程序。谢谢,这很有帮助。我包括了一个path标记,并在updateDatabase标记中引用了它。
<path id="liquibaseClasspath">
    <fileset dir="C:\projects\lbdemo\trunk\lib" includes="*.jar" />
</path>
<target name="Upgrade_db">
    <echo message="Upgrading DataBase" />
    <updateDatabase changeLogFile="C:\projects\lbdemo\trunk\db_v4.xml" driver="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}"  classpathref="liquibaseClasspath" />
</target>