热部署可以在不关闭Tomcat的状况下直接将war包部署到服务器上。web
须要修改tomcat的conf/tomcat-users.xml配置文件。添加用户名、密码、权限。apache
<role rolename="manager-gui" /> <role rolename="manager-script" /> <user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/>
启动服务器点击这个连接进入后台管理功能
这里输入刚才设置的密码就能够进去了
在这里选择本身的war包就能够直接部署。tomcat
若是在上面选择的话,仍是有点麻烦,这里咱们直接在本身的代码中就经过Maven就能够直接部署。
在web项目中的pom.xml文件中配置,这里须要注意的是目录必须是/manager/text服务器
<!-- 配置tomcat插件 --> <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <path>/</path> <port>8080</port> <url>http://192.168.25.134:8080/manager/text</url> <username>tomcat</username> <password>tomcat</password> </configuration> </plugin> </plugins> </build>
使用Maven部署项目,由于Tomcat中有原来的项目因此须要使用redeploy这个命令。
-DskipTests的意思跳过测试。maven
clean tomcat7:redeploy -DskipTests
ok,项目部署成功:测试