网上有很多关于tomcat7-maven-plugin插件中的deploy使用说明,但都不是很具体,经过不断重试整理如下。
1)
deploy是基于tomcat的manager功能的,首先配置manager相关的角色
在文件中配置apache-tomcat-7.0.54\conf\tomcat-users.xml
<role rolename="manager-script"/><!--脚本发布 -->
<role rolename="manager-gui"/><!--人工发布 -->
<user username="deployer" password="s3cret" roles="manager-script"/>
<user username="admin" password="admin" roles="manager-gui"/>
2)插件tomcat7-maven-plugin属性配置
<configuration>
<path>/static</path>//定义应用的访问上下文
<update>true</update>
<uriEncoding>UTF-8</uriEncoding>
<finalName>static</finalName>
<url>http://localhost/manager/text</url>
<!-- http://localhost/manager/html 是基于页面操作的发布,text是基于脚本的发布,很多介绍都把此处写成html了 -->
<username>deployer</username> <!-- 脚本发布时使用的用户名,密码-->
<password>s3cret</password>
<server>tomcat</server>
<!--如果不想在上面暴露用户名密码,可以将用户密码配置到 maven settings.xml 中-->
</configuration>
3)。。。。conf\settings.xml
<server>
<id>tomcat</id>
<username>deployer</username>
<password>s3cret</password>
</server>
4)启动tomcat ,执行tomcat7:deploy即可发布到tomcat中
http://localhost/manager/html 使用manager-gui角色对应的用户进入,可以看到新deploy的应用