eclipse 收到错误“无法从资源 net/sf/antcontrib/antcontrib.properties 加载定义。无法找到。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15304845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting an error "Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found."
提问by gauravhalbe
I am getting an error Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.
when I am trying to ant build on eclipse. So I downloaded ant-contrib-0.6.jar and kept it in my /lib
location of apache ant, but it still does not resolve my issue. I have also tried by specifying the /lib
location in my CLASSPATH
system variable. How can I get around this error?
Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.
当我尝试在 Eclipse 上构建 ant 时出现错误。所以我下载了 ant-contrib-0.6.jar 并将它保存在我/lib
的 apache ant 位置,但它仍然没有解决我的问题。我也尝试过/lib
在我的CLASSPATH
系统变量中指定位置。我怎样才能解决这个错误?
回答by Boris Brodski
You can provide full path to the ant-contrib JAR explicitly using "classpath" element:
您可以使用“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>
回答by Eugene Gr. Philippov
One important thing missing from this StackOverflow page is that setting the correct ANT_HOME env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. This missing thing has costed me a few hours. =)
此 StackOverflow 页面缺少的一件重要事情是设置正确的 ANT_HOME env var 绝对至关重要且重要,如果没有此设置,无论您将 ant-contrib-1.0b3.jar 复制到文件系统的何处,ant 都会不断提示相同的错误. 这个丢失的东西花了我几个小时。=)
However I receive this error without eclipse, in the pure ant.
但是,在纯蚂蚁中,我在没有日食的情况下收到此错误。
回答by Alexandre Blais
I fixed that this way:
我是这样解决的:
Add the JAR to the Ant runtime classpath entries.
将 JAR 添加到 Ant 运行时类路径条目。
Window>Preferences>Ant>Runtime>Classpath
Window>Preferences>Ant>Runtime>Classpath
Add the JAR to either Ant Home Entries or Global Entries.
将 JAR 添加到 Ant Home Entries 或 Global Entries。
回答by Mark O'Connor
It would appear that you haven't installed the ant contrib jar into the correct lib directory. This can be difficult to do if you have several installations of ANT.
看起来您还没有将 ant contrib jar 安装到正确的 lib 目录中。如果您有多个 ANT 安装,这可能很难做到。
My suggestion is to install your ANT plugins into the "$HOME/.ant/lib" directory. You could go one step further and automate the process as follows:
我的建议是将您的 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>
回答by Ankit Adlakha
Use the below mentioned code in your build xml:
在您的构建 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>
And in your build property file:
在您的构建属性文件中:
ant.jarPath=D:/antjars
ant.jarPath=D:/antjars
And place ant.jar and ant-contrib-0.3.jar in directory:D:/antjars
并将 ant.jar 和 ant-contrib-0.3.jar 放在目录:D:/antjars
回答by 79E09796
Check you have read permissions for the ant-contrib jar file.
检查您是否拥有 ant-contrib jar 文件的读取权限。
In our case after copying the file with another user it did not, giving the same error message.
在我们的情况下,在与另一个用户复制文件后,它没有,给出相同的错误消息。