简体   繁体   English

Tomcat管理器的Java包装器类/库

[英]Java wrapper class/library for Tomcat manager

I am wondering if there is a simple wrapper class/library for the Tomcat Manager application. 我想知道Tomcat Manager应用程序是否有一个简单的包装类/库。 I am writing a script to deploy my war to a remote instance of Tomcat (hosted on AWS). 我正在编写脚本以将战争部署到Tomcat的远程实例(托管在AWS上)。

I know I can directly use HTTP to communicate with the manager script interface, but I thought this would be a common problem, so I do not want to re-invent the wheel. 我知道我可以直接使用HTTP与管理器脚本接口进行通信,但是我认为这将是一个普遍的问题,因此我不想重新发明轮子。 I found a python solution here , and this question talks about using curl, but I can't find a java solution (which is funny, Tomcat is used by Java developers, not bash developers!) Can someone please point me in the right direction? 我在这里找到了python解决方案, 这个问题涉及使用curl,但是我找不到Java解决方案(这很有趣,Tomcat是Java开发人员使用的,而不是bash开发人员!)有人可以指出正确的方向吗? ?

I found what I needed in this answer . 我在这个答案中找到了我需要的东西。 I can use the Tomcat Ant library. 我可以使用Tomcat Ant库。 In order to do so, all I need is the catalina-ant.jar from $CATALINA_HOME/lib in my project's dependencies. 为此,我需要的是项目依赖项中$CATALINA_HOME/lib中的catalina-ant.jar

org.apache.catalina.ant.DeployTask task = new org.apache.catalina.ant.DeployTask();
task.setUrl("http://localhost:8084/manager");
task.setUsername("managerLogin");
task.setPassword("managerPassword");
task.setPath("/UrlToYourDeploadingProject");
task.setWar(new File("c:/Project.war").getAbsolutePath());
task.execute();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM