问题
I need some help: I have two .war files running on tomcat 7, one is a webapplication, the other one is just a "normal" java application. Now I want to figure out how to start/stop the application from my webapplication. Both applications are on the same tomcat. Operation system is Ubuntu 14.04.
Thanks for your help
回答1:
you can configure that in your server.xml
file and put 2 services :
<Service name="app1">
<Connector port="8081" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="app1"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
<Service name="app2">
<Connector port="8082" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="app2"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
Then the application will run on
- app1 on http://localhost:8081
- app2 on http://localhost:8082
Resource Link:
- Listen Multiple Ports in Tomcat
- How to run different apps on single Tomcat instance behind different ports?
来源:https://stackoverflow.com/questions/37807422/how-to-start-stop-an-application-from-a-webapplication-running-both-on-same-tomc