Ini akan menghapus halaman "在tomcat容器中部署多个service"
. Harap dipastikan.
1.在tomcat容器中部署多个service
在server.conf中配置
[html] view plain copy
<?xml version='1.0' encoding='utf-8'?>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="discoveryServiceDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="configurationServiceDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
<Connector port="8761" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="discoveryService" defaultHost="discoveryHost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="discoveryServiceDatabase"/>
</Realm>
<Host name="discoveryHost" appBase="discoveryapp" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="discovery_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
<Connector port="1221" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8445" />
<Connector port="8011" protocol="AJP/1.3" redirectPort="8445" />
<Engine name="configurationService" defaultHost="configurationHost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="configurationServiceDatabase"/>
</Realm>
<Host name="configurationHost" appBase="configurationapp" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="configuration_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
上面这样子配置完之后 tomcat启动 可以用以下url访问对应的service
localhost:8761/ localhost:8080/ localhost:1221/
注意点: 1 service标签name不能重复 2.connector中的端口号不能重复 3.realm中的resourceName 对应上面的resource标签 4.host中的appBase的目录从tomcat安装目录开始 {TOMCAT_HOME}/{对应的目录名字} 5.重点:上述的配置war包名字必须是ROOT,而且没有虚拟路径。虚拟路径需要在host标签新增下面属性: docBase 是war包的路径,path是虚拟路径,虚拟路径的名称必须和war包名称一致
2.2tomcat中添加用户权限 tomcat-users.xml [html] view plain copy <tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
重启tomcat后 访问页面 http://172.19.103.33:8761/manager/html
就可以通过上面的按钮去重启service 注意点: 1.改种方式 要考虑安全性 建议部署tomcat在内网
重启的rest接口
HEADER中要放入Basic验证信息 Authorization Basic Y3dkOmN3ZA== (在tomcat-users.xml配置的账号密码的加密 格式 cwd:cwd )
GET http://172.19.103.33:8761//manager/text/reload?path=/ path代表项目的目录 /默认是 ROOT目录
请求成功后返回message OK - Reloaded application at context path
例如
返回请求
ps:博客链接: http://blog.csdn.net/whiteforever/article/details/78869364
Ini akan menghapus halaman "在tomcat容器中部署多个service"
. Harap dipastikan.