ANT - 无法加载依赖类 com/jcraft/jsch/Logger [英] ANT - Could not load a dependent class com/jcraft/jsch/Logger
问题描述
我的 Ant 脚本有问题.
I have a problem with my Ant script.
我需要复制一个文件到 Linux 服务器
I need to copy a file to Linux server
<copy file="../Ant/lib/jsch-0.1.50.jar" tofile="${ant.home}/lib/jsch-0.1.50.jar" />
<scp todir="${server.user}:${server.password}@${server.dev}:${server.dev.dir.config}" trust="true" verbose="true">
<fileset dir="${src.home}/Config/">
<include name="**/*" />
</fileset>
</scp>
文件被正确复制,但我收到此错误:
File is copied correctly, but I receive this error:
BUILD FAILED
C:\dev.xml:179: Problem: failed to create task or type scp
Cause: Could not load a dependent class com/jcraft/jsch/Logger
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:\Progs\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\lib
-C:\Users\Administrator\.ant\lib
-a directory added on the command line with the -lib argument
如何在 Ant 类加载器中动态添加这个 JAR?
How can I dynamically add this JAR in the Ant classloader?
推荐答案
Exception 本身很清楚,指出了问题的原因:
The Exception itself is quite clear and points the reason of the problem:
Action: Determine what extra JAR files are needed, and place them in one of:
-C:\Progs\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\lib
-C:\Users\Administrator\.ant\lib
-a directory added on the command line with the -lib argument
请从库依赖项
jsch.jar 0.1.50 或更高版本:sshexec 和 scp 任务(http://www.jcraft.com/jsch/index.html)
jsch.jar 0.1.50 or later: sshexec and scp tasks (http://www.jcraft.com/jsch/index.html)
如果您将这个库复制到 ant 库中,它将解决独立 Ant 的问题.
If you copy this lib in the ant lib it will solve the issue for the standalone Ant.
对于 Eclipse:进入 Eclipse 首选项,在 Ant/Runtime 条目中,在类路径"选项卡中.使用添加外部罐子"按钮将您的 jsch.jar 添加到 Ant 的类路径.
And for the case of Eclipse: Go into the Eclipse Preferences, in the Ant/Runtime entry, in the 'Classpath' tab. Use the button 'Add External Jars' to add your jsch.jar to Ant's classpath.
这篇关于ANT - 无法加载依赖类 com/jcraft/jsch/Logger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!