收到错误“无法加载资源net / sf / antcontrib / antcontrib.properties中的定义。无法找到它。”

时间:2013-03-08 23:06:02

标签: eclipse ant ant-contrib

当我尝试在eclipse上构建ant时,我收到错误Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.。所以我下载了ant-contrib-0.6.jar并将其保存在apache ant的/lib位置,但它仍然无法解决我的问题。我还尝试在/lib系统变量中指定CLASSPATH位置。我怎样才能解决这个错误?

6 个答案:

答案 0 :(得分:23)

您可以使用“classpath”元素显式提供ant-contrib JAR的完整路径:

<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
  </classpath>
</taskdef>

答案 1 :(得分:7)

这个StackOverflow页面遗漏的一件重要事情是设置正确的ANT_HOME env var绝对至关重要且没有这个设置蚂蚁不断告诉同样的错误,无论你在哪里复制ant-contrib-1.0b3.jar你的文件系统。这个丢失的东西花了我几个小时。 =)

然而,我在纯蚂蚁中没有日食就收到了这个错误。

答案 2 :(得分:4)

我这样解决了:

将JAR添加到Ant运行时类路径条目。

Window>Preferences>Ant>Runtime>Classpath

将JAR添加到Ant Home Entries或Global Entries。

答案 3 :(得分:1)

您似乎没有将ant contrib jar安装到正确的lib目录中。如果您有多个ANT安装,这可能很难做到。

我的建议是将ANT插件安装到“$ HOME / .ant / lib”目录中。您可以更进一步,按如下方式自动执行该过程:

<project name="ant-contrib-tasks" default="all">

    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <target name="bootstrap">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
    </target>

    <target name="all">
        <for param="file">
            <fileset dir="." includes="*.txt"/>
            <sequential>
                <echo message="Found file @{file}"/>
            </sequential>
        </for>
    </target>

</project>

答案 4 :(得分:0)

在build xml中使用下面提到的代码:

<path id="ant.classpath">
<pathelement location="${ant.jarPath}/ant.jar" />
<pathelement location="${ant.jarPath}/ant-contrib-0.3.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
 <classpath refid="ant.classpath" />
</taskdef>

在你的构建属性文件中:

ant.jarPath = d:/ antjars

将ant.jar和ant-contrib-0.3.jar放在目录中:D:/ antjars

答案 5 :(得分:0)

检查您是否具有ant-contrib jar文件的读取权限。

在我们的情况下,在与另一个用户复制文件之后它没有,给出相同的错误消息。

相关问题