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

gau*_*lbe 18 eclipse ant ant-contrib

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位置,但它仍然无法解决我的问题.我也尝试过/libCLASSPATH系统变量中指定位置.我怎样才能解决这个错误?

Bor*_*ski 26

您可以使用"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>
Run Code Online (Sandbox Code Playgroud)

  • 将你的`ant-contrib - *.jar`放入$ HOME/.ant/lib并重启Eclipse.这也适用于Windows. (6认同)

Eug*_*pov 7

这个StackOverflow页面缺少的一件重要事情是,设置正确的ANT_HOME env var绝对至关重要且没有这个设置,不管你在文件系统上复制ant-contrib-1.0b3.jar的位置,ant都会一直告诉同样的错误.这个丢失的东西花了我几个小时.=)

但是我在纯蚂蚁中没有日食就收到了这个错误.

  • 是的,Eclipse为您配置了它。顺便说一句,如果您下载apache-ant,将其解压缩并运行`bin \ ant.bat`或`bin / ant`,则ANT_HOME将自动设置。 (2认同)

小智 5

我以这种方式解决了这个问题:

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

Window>Preferences>Ant>Runtime>Classpath

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