Problem
When running an optional Ant task (e.g. scp or sshexec ) through the Eclipse Ant interface, you get an error similar to the one below.
BUILD FAILED
C:\Path\To\build.xml:45: Problem: failed to create task or type scp
Cause: Could not load a dependent class com/jcraft/jsch/UserInfo
It is not enough to have Ant's optional JARs
you need the JAR files that the optional tasks depend upon.
Ant's optional task dependencies are listed in the manual.
Action: Determine what extra JAR files are needed, and place them in one of:
-C:\Path\To\Ant\Home\lib
-C:\Path\To\User\Home\.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
However, you have found all required dependencies for the tasks you are trying to use and put them in one of the folders as specified.
Cause
Although you have added the right dependencies, Eclipse might not yet know of the file(s). If this is the case, you can see this by running Ant diagnostics (ant -diagnostics on the command line or the <diagnostics> ant task). You will see that the dependency is listed in the appropriate “lib jar listing” but is missing in the java.class.path system property.
Solution
Go to Window > Preferences > Ant > Runtime > Classpath , select “Ant Home Entries (default)” and click “Add External JARs…”. Select the required dependency or dependencies and accept. Now, the selected JAR files will be loaded to the class path and the optional ant task depending on them will work.
本文介绍了解决在Eclipse中使用Ant时出现的“Couldnotloadadependentclass”错误的方法。该问题通常发生在尝试运行scp或sshexec等可选Ant任务时,原因是缺少必要的依赖项。文章提供了检查依赖、配置路径的具体步骤。
4万+

被折叠的 条评论
为什么被折叠?



