eclipse + maven + tomcat 热部署

热部署指在eclipse就可以运行调试maven项目。

1. 编辑 tomcat 文件:tomcat-users.xml 添加如下内容:

<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,admin-gui"/>

2. 在 maven 安装目录conf/settings.xml 文件中加入一个server:

<server>
        <id>tomcat7</id>
        <username>admin</username>
        <password>admin</password>
    </server>

3. 在项目pom.xml文件中加入插件:

<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/</path>
                    <port>8080</port>
                    <uriEncoding>UTF-8</uriEncoding>
                    <url>http://localhost:8080/manager/text</url>
                    <server>tomcat7</server>
                </configuration>
            </plugin>

4. 然后 maven 编译项目之后,使用 mvn tomcat7:redeploy 即可部署启动项目,当然 tomcat 要提前启动。


问题:

1. 第二次部署时提示出错:

[INFO] FAIL - Unable to delete [D:\j2ee\apache-tomcat-7.0.52\webapps\ROOT]. The continued presence of this file may cause problems.
[INFO] FAIL - Application already exists at path /

也就是ROOT目录删除不了,不让部署。

网上google之后,发现解决办法:

http://stackoverflow.com/questions/14873219/cannot-undeploy-a-web-app-completely-in-tomcat-7

修改 D:\j2ee\apache-tomcat-7.0.52\conf\context.xml文件

修改开头的<Context> 为 <Context antiResourceLocking="true" > 即可。

2. 第二次部署时出错:

[INFO] FAIL - Context / is defined in server.xml and may not be undeployed
[INFO] FAIL - Application already exists at path /

解决办法:

解决方法是在pom.xml文件中配置tomcat7-maven-plugin插件时加入参数update
<update>true</update> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值