gpt4 book ai didi

java - ant 目标部署 war 到 tomcat7/webapps

转载 作者:行者123 更新时间:2023-11-30 07:14:52 26 4
gpt4 key购买 nike

我想部署刚刚创建的 *.war (展开)到 ${TOMCAT_HOME}/webapps使用 ant目标。

配置

我的 tomcat 版本是 7.0.37 和 tomcat-users.xml是:

  <role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager-gui"/>

<user username="tomcat" password="tomcat" roles="tomcat,manager-gui"/>
<user username="both" password="tomcat" roles="tomcat,role1,manager-gui"/>
<user username="role1" password="tomcat" roles="role1"/>

war.properties是:

# War Build Properties

package.dir=${basedir}/package
war.exploded.dir=${deploy.dir}/war-ex
# --------- Tomcat Settings ---------------

# FIXME : tomcat.url=http://localhost:8080/manager/text
tomcat.url=http://localhost:8080/manager

tomcat.username=tomcat
tomcat.password=tomcat

context-path=/eccount

我的 deploy-war目标如下(tomcat-deploy.xml):

<taskdef name="catalina-deploy"    classname="org.apache.catalina.ant.DeployTask"       classpathref="catalina.lib.classpath"/>
<target name="deploy-war" depends="build-wardir" description="Install web app">
<catalina-deploy url="${tomcat.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="${context-path}"
localwar="file://${war.exploded.dir}"/>
</target>

问题

当我点击 ant deploy-war通过命令行,我得到以下异常:

FileNotFoundException : http://localhost:8080/manager/deploy?path=%2Feccount&war=file%3A%2F%2FC%3A%5Ceccount%2Fdeploy%2Fwar-ex

但是,同样的路径file:///C:/eccount/deploy/war-ex可通过网络浏览器访问。

引用文献

Deploy A New Application Remotely in Tomcat 7.0.37

Deployment of war file on Tomcat

How Apache Ant deploys .war file to Tomcat

Catalina-Ant for Tomcat 7

最佳答案

好了,问题已经解决了:

第 1 步:更新 AT7 的 tomcat 管理器 url

 tomcat.url=http://localhost:8080/manager/text

第 2 步:为用户添加额外的角色

  <role rolename="manager-script"/>

<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,manager-script"/>

感谢Ant Tomcat 7 Reload FileNotFoundException

关于java - ant 目标部署 war 到 tomcat7/webapps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18274002/

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