【问题标题】:Cause: the class org.apache.tools.ant.taskdefs.optional.XMLValidateTask was not found原因:未找到类 org.apache.tools.ant.taskdefs.optional.XMLValidateTask
【发布时间】:2018-09-12 03:35:28
【问题描述】:

我遇到了 Ant 问题。我在 build.xml 中使用 xmlvalidate 标记。

        <xmlvalidate file="${basedir}/**/@{filename}" failonerror="true">
            <attribute name="http://xml.org/sax/features/validation" value="true" />
            <attribute name="http://apache.org/xml/features/validation/schema" value="true" />
            <attribute name="http://xml.org/sax/features/namespaces" value="true" />
        </xmlvalidate>

我收到以下错误

Problem: failed to create task or type xmlvalidate
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.XMLValidateTask was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME\lib

我对此进行了很多探索并尝试了一些建议: 1)我搜索了包含 org.apache.tools.ant.taskdefs.optional.XMLValidateTask 的 jar 文件(添加了 ant-optional-1.5.1.jar)并添加到 ANT_HOME\lib 文件夹中,因为它在错误。 2)我现在用的是ant 1.9.7,更新到1.10.5。

使用任何一个选项我都没有成功。

从错误中我了解到的只是缺少一些 jar..

请帮助解决这个问题。提前感谢您的时间...

【问题讨论】:

    标签: java ant


    【解决方案1】:

    您必须将 ant 可选 jar 添加到类路径并引用该类路径。

    <property name='lib.dir' value='lib' />
    
    <path id='classpath'>
        <fileset dir="${lib.dir}" includes="**/*.jar" />
    </path>
    

    【讨论】:

      猜你喜欢
      • 2012-05-24
      • 2017-11-05
      • 2020-03-16
      • 2014-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多