Maven自动部署测试Web应用

发表于:2016-3-04 10:42

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:chuiyuan    来源:51Testing软件测试网采编

  一、在maven中使用内嵌tomcat部署测试Web应用
  只使用最简单的java web作为例子。
  此时可以使用maven内嵌的tomcat,中间要用到tomcat-maven-plugin,这里不用设置plugin的repository,它会自动下载tomcat-maven-plugin和tomcat 。
  只使用命令
  mvn tomcat:run
  就可以了。
  如果这里我们使用命令
  mvn tomcat:deploy
  会出现can not invoke tomcat manager的错误。这是因为没有对tomcat manager的设置。
  二、在maven中使用外部tomcat部署web应用
  此时使用的tomcat为自己安装的,要对tomcat和maven都进行设置。
  maven要想链接上tomcat,要有三个步骤:
  一是设置tomcat的manager帐号,二是下载可以链接外部tomcat的plugin,三是配置maven setting.xml文件中的server为tomcat的manager。
  注意:使用外部的tomcat,要使用最新版本的tomcat6(or7)-maven-plugin。
  (1)设置tomcat 的manager帐号
  在文件tomcat-path/conf/tomcat-user.xml中加入如下
  (2)配置maven setting.xml
  对个单个用户,配置的是~/.m2/setting.xml。
  (3)下载可以链接外部 tomcat的plugin
  在项目的pom.xml中加入plugin.
  maven下载plugin和一般库的repo不同,接下来配置repo。
<span style="font-size: 16px;"><!---->
<!--if no repository defined, there will be error:-->
<!--No plugin found for prefix 'tomcat7' in the current project and in the plugin groups for ..-->
<!--from the repository [local],central (https://repo.maven.apache.org.maven2-->
<repositories>
<repository>
<id>people.apache.snapshots</id>
<url>http://repository.apache.org/content/groups/snapshots-group</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Apache Snapshots</name>
<url>http://repository.apache.org/content/groups/snapshots-groups</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</span>
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号