ant自动上传

1、下载jsch.jar

http://sourceforge.NET/projects/jsch/files/jsch.jar/

2、保存一下内容,命名为build.xml在d:/antHome目录下

<project name="AntAutoDeploy" basedir="../" default="scp">
    <target name="scp">
        <scp file="myfile.txt" todir="[email protected]:/home/" trust="true" password="123456" />
    </target>
</project>

3、把jsch.jar复制到d:/antHome下

4、执行 ant -lib d:/antHome

在eclipse运行需要下载jsch.jar 并且设置到eclipse中

运行build.xml出现异常:

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.

解决方法: 加入jsch-x.x.x.jar

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

猜你喜欢

转载自blog.csdn.net/shizhan1881/article/details/71336019