gpt4 book ai didi

java - 如何通过 Ant build.xml 文件将 war 文件发送到 Windows 机器位置

转载 作者:可可西里 更新时间:2023-11-01 11:27:47 24 4
gpt4 key购买 nike

我已经设置了一个环境,在这个环境中,我所有的 svn check out /更新、编译、制造 war 、创建所需环境的过程都是使用 Ant build.xml 完成的。我也愿意通过 Ant build.xml 部署构建的 war 文件。

我成功地使用 build.xml 将应用程序部署到 Linux 机器上,使用 SCP 任务通过以下代码部署到 Tomcat webapps 目录。

<target> <scp trust="true" file="antproject1.war" 
todir="${tomcat.username}@${tomcat.server}:${tomcat.webapps.dir}"
password="${tomcat.password}"/> </target>

但我不知道要使用什么任务将哪些 jar 文件添加到 ANT_HOME,以便将 war 文件从我的本地机器发送到远程 Windows 机器。

最佳答案

Windows 本身不支持 SCP。

您可以安装第 3 方 SCP 服务器。尽管大多数优秀且易于安装的 SCP 服务器都是商业服务器。


native 仅支持 FTP(或 FTPS),尤其是 Windows IIS 服务器。
查看我的指南Installing secure FTP server on Windows using IIS .

运行 FTP 服务器后,使用 Ant FTP task .

<ftp server="example.com" userid="username" password="password">
<fileset dir="path">
<include name="antproject1.war"/>
</fileset>
</ftp>

有关更多示例,请参阅 Ant FTP task documentation .

不过请注意,不幸的是 Ant FTP 任务不支持 TLS/SSL 加密。因此,与我的指南中的建议相反,您必须允许与 IIS 的未加密连接。


如果你想使用安全连接,你必须使用an Ant Exec task并运行外部 FTPS 客户端。

例如 WinSCP :

<exec executable="winscp.com">
<arg value="/command"/>
<arg value="open ftps://username:password@example.com/"/>
<arg value="put c:\localpath\antproject1.war /remote/path/"/>
<arg value="exit"/>
</exec>

有关详细信息,请参阅 guide to WinSCP scripting .

优势可能是 WinSCP 也支持 SCP(和 SFTP)协议(protocol)。因此,对于 Linux SCP/SFTP 和 Windows FTP/FTPS,您可能拥有相同的代码(session URL 除外)。

(我是 WinSCP 的作者)

关于java - 如何通过 Ant build.xml 文件将 war 文件发送到 Windows 机器位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30321968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com