如何解决“原因:找不到类org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"在运行“蚂蚁测试"时? [英] How to solve "Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found." while running "ant test"?

查看:33
本文介绍了如何解决“原因:找不到类org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"在运行“蚂蚁测试"时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 test 的目标,我想做一些测试.

I have a target named test and I want to do some tests.

我把重要的部分放在 build.xml 中.它包括:

I put here the important parts in build.xml. It includes:

<property name='lib.dir' value='lib' />

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

并且我已经将 junit.jarant-junit.jar(它是必须的吗?)放在 lib 目录中.

And I have put the junit.jar and ant-junit.jar(is it a must?) in the lib directory.

但是,如果我运行

蚂蚁测试.

输出错误为:

test:

BUILD FAILED
/home/xiaohan/EclipseWorkSpace/AntTest/build.xml:82: Problem: failed to create task or type junit
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.
        This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
        -/usr/share/ant/lib
        -/home/xiaohan/.ant/lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem

另外,如果我把两个jar文件放在/usr/share/ant/lib中,设置了$ANT_HOME,还是不行.

Additionally, if I put the two jar files in /usr/share/ant/lib with the $ANT_HOME set, it still does not work.

非常感谢您的任何提示

推荐答案

就我而言(使用 Mint,基于 Debian)

In my case (using Mint, based on Debian)

sudo apt-get install ant-optional

是唯一有效的方法.

这篇关于如何解决“原因:找不到类org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"在运行“蚂蚁测试"时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆