Ant 构建拒绝复制 .war 文件的权限
我有一个打包的 app.war 文件,我试图将其复制到 webapps 文件夹,但收到错误:
BUILD FAILED 由于 java.io.FileNotFoundException /usr/local/tomcat/webapps/mywar.war (权限被拒绝),无法将 mywar.war 复制到 /usr/local/tomcat/webapps/mywar.war (权限被拒绝)
以下是 ant 代码:
<target name="install" depends="package">
<copy file="mywar.war" tofile="${webapp.dir}/mywar.war" overwrite="true" />
</target>
这显然是一个权限问题。我无法通过 chmod 777 .war 文件真正解决它,因为 myapp.war 每次都会被删除,并且新文件将再次应用限制性权限。
如果我将整个 webapps 目录权限设置为 777 之类的怎么办?就安全性而言,这似乎是不好的做法,对吧?或者有没有ant命令给脚本root权限?如果重要的话我正在使用 ubuntu。
谢谢!
I have a packaged app.war file that I am trying to copy to the webapps folder and I am getting an error:
BUILD FAILED
Failed to copy mywar.war to /usr/local/tomcat/webapps/mywar.war due to java.io.FileNotFoundException /usr/local/tomcat/webapps/mywar.war (Permission denied)
Here is the ant code for this:
<target name="install" depends="package">
<copy file="mywar.war" tofile="${webapp.dir}/mywar.war" overwrite="true" />
</target>
It is obviously a permissions thing. I can not really solve it by chmod 777 the .war file because the myapp.war will get erased every time, and the new files will have the restrictive permissions applied again.
What if I make the whole webapps dir permissions 777 or something? That seems like bad practice in terms of security, right? Or is there an ant command to give the script root permission? I am using ubuntu if it matters.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我使用 Ant 构建 WAR 文件,然后
su
到 root 并手动将其复制到webapps
文件夹中。但是,您可以使
webapps
文件夹可由特定组写入,并作为该组的成员运行 Ant。Personally, I build the WAR file with Ant, and then
su
to root and copy it to thewebapps
folder by hand.However, you could make the
webapps
folder writable by a particular group, and run Ant as a member of that group.尝试使用
scp
任务。您需要确保 jsch 位于 Ant 类路径上才能正常工作。 Ant 人员有相关文档。Try using the
scp
task. You'll need to make sure jsch is on the Ant classpath for it to work. There's documentation from the Ant folks about it.