我正在关注春季教程。因为它用蚂蚁任务控制tomcat。早些时候我遇到了一些问题,因为 tomcat 7 manager 应用程序与以前的版本不同。但我能够修复它们。现在 ant listtask 工作正常。但其他人不是。例如 ant starttask 返回此错误。
start-webapp:
BUILD FAILED
C:\Users\rsenarath\workspace\myspringapp\build.xml:108: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/start?path=%2Fmyspringapp
但是,当我在浏览器上复制 url(http://localhost:8080/manager/text/start?path=%2Fmyspringapp) 时,它会要求输入用户名密码,并且它的回复没有问题,如下所示。
OK - Started application at context path /myspringapp
有人可以帮我弄这个吗。我的 build.properties 如下
appserver.name=tomcat
appserver.home=C:/Users/rsenarath/apache-tomcat-7.0.34
appserver.lib=${appserver.home}/lib
appserver.bin=${appserver.home}/bin
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager/text
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret
和ans任务如下
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
<taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/>
<target name = "stop-webapp">
<catalina-stop url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${name}"
failonerror="false"/>
</target>
<target name = "start-webapp">
<catalina-start url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${name}"/>
</target>
<target name="list-webapp" description="List Tomcat applications">
<catalina-list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"/>
</target>