Tomcat有个manager项目,平常都是删除的,前段时间考虑感受下它的功能所以就搭建了一下,感觉效果不错。
记录下过程:
1,首先你要保证你的配置中开启了对tomcat的登录配置,可以参考下面的配置
<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <tomcat-users> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. --> <!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them. --> <!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> <role rolename="manager-gui"/> <user username="admin" password="admin" roles="admin,manager,manager-gui"/> </tomcat-users>
这个配置文件在apache-tomcat-7.0.34\conf目录下,名称是tomcat-users.xml
然后我们找到webapp目录,下面有一个manager项目(没有也没关系,你可以再去下载一个tomcat然后把这个项目复制过来,或者去别人的tomcat下拷贝一下也可以)
关于其他的部分我们略过,然后启动tomcat,访问/manager项目,然后按照你配置的username和password登录,然后我们就可以看到并控制这些项目了(p.s 吐糟一下,其实这东西就是利用ant的一些命令而已,更好玩的玩法可以结合svn增量部署~~具体的我就先不说了)
然后部署你的项目war包时可以命名为 项目名##1.war 项目名##2.war... 这样可以同时部署多个版本,这个时候老的session还存活则继续访问1版本,新建的session则访问新版本,当老版本session都消亡的时候你就可以deploy第一个版本了(当然像我这么暴力的都是直接停掉第一个版本)
我的原则一般是停一个运行一个~~万一不对立即重新启动原来的~~
最后提醒你~如果就这么运行那没问题,但是如果你开启了自动解包,那么万一需要重启的时候一定记得要把版本移除一些,只留一个两个就行了,否则你的内存爆了,或者干脆启动不起来,我可提醒过你了~~·哈哈哈