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查找jdbc驱动程序类问题_Ant_Jdbc_Classnotfoundexception_Liquibase - Fatal编程技术网

使用liquibase、ant查找jdbc驱动程序类问题

使用liquibase、ant查找jdbc驱动程序类问题,ant,jdbc,classnotfoundexception,liquibase,Ant,Jdbc,Classnotfoundexception,Liquibase,下面是我的ant xml文件的一个示例: <!--A reference to the classpath that contains the database driver, liquibase.jar, and the changelog.xml file--> <path id="liquibase.classpath.id"> <pathelement location="${PROJECT_DIR}/lib/liquibase-2.0.2.jar"/

下面是我的ant xml文件的一个示例:

<!--A reference to the classpath that contains the database driver, liquibase.jar, and the changelog.xml file-->
<path id="liquibase.classpath.id">
   <pathelement location="${PROJECT_DIR}/lib/liquibase-2.0.2.jar"/>
   <pathelement location="${jdbc.classpath}"/>
   <fileset dir="${PROJECT_DIR}/db/changelog" includes="db.changelog*.xml"/>
</path>

<pathconvert refid="liquibase.classpath.id" property="liquibase.classpath.id.text" />
<echo message="${liquibase.classpath.id.text}"  />

<updateDatabase loglevel="debug"
        changeLogFile="${db.changelog.file}"
        driver="${jdbc.driver}"
        url="${jdbc.url}"
        username="${database.username}"
        password="${database.password}"
        dropFirst="false"
        classpathref="liquibase.classpath.id"
        />
但是
updateDatabase
引发以下异常:

java.lang.ClassNotFoundException: org.hsqldb.jdbc.JDBCDriver

我做错了什么?请告诉我

我看不到您在哪里定义
jdbc.driver
,但是类名应该是,而不是
org.hsqldb.jdbdriver
我看不到您在哪里定义
jdbc.driver
,但是类名应该是,而不是
org.hsqldb.jdbdriver
这是hsqldb的驱动程序的名称吗?我看到的文档显示org.hsqldb.jdbc.JDBCDriver。

这是hsqldb的驱动程序的名称吗?我看到的文档显示org.hsqldb.jdbc.JDBCDriver。

正如前面指出的,jdbc驱动程序应该是org.hsqldb.jdbc.JDBCDriver。我认为您的第二个问题是ANT找不到您的HSQLDBJAR文件。你绝对确定路径正确吗

下面是我的工作示例(我将类路径管理委托给插件)

液化酶性质 编译文件

未设置db.changelog.file
未设置db.url
db.driver未设置
未设置db.username
db.password未设置
ivy.xml Build配置为下载最新版本,可从Maven Central获得

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="scott-tiger"/>
    <configurations defaultconfmapping="ant->default">
        <conf name="ant" description="Ant build dependencies"/>
    </configurations>
    <dependencies>
        <dependency org="org.liquibase" name="liquibase-core" rev="latest.release"/>
        <dependency org="org.hsqldb" name="hsqldb" rev="latest.release"/>
    </dependencies>
</ivy-module>

正如前面指出的,JDBC驱动程序应该是org.hsqldb.JDBC.JDBCDriver。我认为您的第二个问题是ANT找不到您的HSQLDBJAR文件。你绝对确定路径正确吗

下面是我的工作示例(我将类路径管理委托给插件)

液化酶性质 编译文件

未设置db.changelog.file
未设置db.url
db.driver未设置
未设置db.username
db.password未设置
ivy.xml Build配置为下载最新版本,可从Maven Central获得

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="scott-tiger"/>
    <configurations defaultconfmapping="ant->default">
        <conf name="ant" description="Ant build dependencies"/>
    </configurations>
    <dependencies>
        <dependency org="org.liquibase" name="liquibase-core" rev="latest.release"/>
        <dependency org="org.hsqldb" name="hsqldb" rev="latest.release"/>
    </dependencies>
</ivy-module>


我已经更新,但同样的错误:java.lang.ClassNotFoundException:org.hsqldb.jdbc.JDBCDriverI已经更新,但同样的错误:java.lang.ClassNotFoundException:org.hsqldb.jdbc.jdbcdrivert您的工作示例和讨论中的示例之间的有益区别是在taskDefahh中包含liquibase类路径,您是对的。那么你作为liquibase:-)伟大图书馆的作者应该是对的@MarkO'Connor,问题的原因是路径中的空间符号。当我将所有JAR和xml更改日志文件放入C:\lib时,它工作了,但C:\..\MyDocuments\lib\。。不起作用。也许有一些配置选项允许我在路径名中使用空格?欢迎使用ivy来管理您的第三方库:-)您的工作示例和讨论中的示例之间的有用区别是在TaskDefahh中包含liquibase类路径,您是对的。那么你作为liquibase:-)伟大图书馆的作者应该是对的@MarkO'Connor,问题的原因是路径中的空间符号。当我将所有JAR和xml更改日志文件放入C:\lib时,它工作了,但C:\..\MyDocuments\lib\。。不起作用。也许有一些配置选项允许我在路径名中使用空格?欢迎使用ivy来管理您的第三方库:-)
<project basedir="." default="build" xmlns:ivy="antlib:org.apache.ivy.ant">

    <!--
    ====================
    Properties and paths
    ====================
    -->
    <property file="liquibase.properties" prefix="db"/>
    <property name="build.dir" location="build"/>
    <property name="db.changelog.file" location="src/scottTiger.xml"/>

    <!--
    =======
    Targets
    =======
    -->
    <target name="init" description="Download 3rd party dependencies">
        <ivy:resolve/>
        <ivy:cachepath pathid="ant.path" conf="ant"/>

        <mkdir dir="${build.dir}"/>
    </target>

    <target name="build" depends="init" description="Create the database">
        <taskdef resource="liquibasetasks.properties" classpathref="ant.path"/>

        <fail unless="db.changelog.file">db.changelog.file not set</fail>
        <fail unless="db.url">db.url not set</fail>
        <fail unless="db.driver">db.driver not set</fail>
        <fail unless="db.username">db.username not set</fail>
        <fail unless="db.password">db.password not set</fail>

        <updateDatabase
            changeLogFile="${db.changelog.file}"
            driver="${db.driver}"
            url="${db.url}"
            username="${db.username}"
            password="${db.password}"
            promptOnNonLocalDatabase="false"
            dropFirst="false"
            classpathref="ant.path"
        />

    </target>

    <target name="clean" description="Cleanup all built files">
        <delete dir="${build.dir}"/>
    </target>

    <target name="clean-all" depends="clean">
        <ivy:cleancache/>
    </target>

</project>
<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="scott-tiger"/>
    <configurations defaultconfmapping="ant->default">
        <conf name="ant" description="Ant build dependencies"/>
    </configurations>
    <dependencies>
        <dependency org="org.liquibase" name="liquibase-core" rev="latest.release"/>
        <dependency org="org.hsqldb" name="hsqldb" rev="latest.release"/>
    </dependencies>
</ivy-module>