2014-01-20 51 views
10

我的Ant腳本存在問題。ANT - 無法加載依賴類com/jcraft/jsch/Logger

我需要將文件複製到Linux服務器

<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> 

文件被正確拷貝,但我收到此錯誤:

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 

我怎樣才能動態將這個JAR添加到Ant類加載器中?

回答

0

使用類似的<copy標記將JSCH的所有依賴關係添加到ANT的lib目錄。

要查找JSCH的依賴關係,請查看其文檔。

8

例外本身是很清楚的,並指出了問題的原因:

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 

請從Library Dependencies

jsch.jar 0.1.50或更高版本檢查:sshexec和scp任務(http://www.jcraft.com/jsch/index.html

如果你在ant lib中複製這個lib,它將解決獨立Ant的問題。

對於Eclipse的情況:進入Eclipse首選項,在Ant/Runtime條目中的'Classpath'選項卡中。使用按鈕'Add External Jars'將jsch.jar添加到Ant的類路徑中。

0

將jsch-0.1.51.jar複製到/ usr/share/ant/lib /(或其他任何目錄)之後,使JAR文件對所有用戶都可讀,而不僅僅是root。不要像我一樣,花半小時試圖弄清楚爲什麼它不起作用。

0

如果你使用Eclipse IDE作爲你從Eclipse中運行螞蟻是不夠的,複製所需的jar文件jsch-0.1.51.jar(或任何版本)。運行時需要更改類路徑ant的用法。

如果您使用的是Windows - >窗口>首選項>螞蟻>運行 如果您使用的是Mac - > Eclipse的>首選項>螞蟻>運行

在Classpath選項卡 「螞蟻家條目...」 你必須添加新的jar。

之後,它的工作。