Maven集成Tomcat7插件自动发布项目总结
程序员文章站
2022-03-14 13:52:26
...
1.[官网][https://tomcat.apache.org/download-70.cgi]]下载tomat7,选择下载core中的tar.gz (pgp, sha512)(apache-tomcat-7.0.104)压缩文件。解压文件找conf目录找到tomcat-users.xml文件,增加如下内容:
<role rolename="manager-gui" />
<role rolename="manager-script" />
<role rolename="admin-gui" />
<role rolename="admin-script" />
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,admin-gui,admin-script" />
2.mavan目录的conf找到settings.xml文件,找到标签,增加如下内容:
<servers>
...
<server>
<id>tomcat7</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
...
</servers>
3.项目pom.xml文件,增加如下内容:
<build>
<finalName>demo</finalName>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://127.0.0.1:8080/manager/text</url>
<server>tomcat7</server>
<username>tomcat</username>
<password>tomcat</password>
<path>/demo</path>
</configuration>
</plugin>
...
</plugins>
</pluginManagement>
</build>
4.控制台进入tomcat的bin目录,执行sh startup.sh ,提示Tomcat started信息 ,tomcat启动成功。打开浏览器录入http://localhost:8080/manager/html ,用户名/密码:tomcat/admin,界面如下 :
5.eclipse开发工具,项目右键 -> Run As -> Run Configurations,Goals填入tomcat7:deploy执行,如下说明成功。
总结:期间执行出现Cannot invoke Tomcat manager: Broken pipe错误,进入tomcat的webapps目录删除之前发布的项目,重新执行tomcat7:deploy,项目启动成功。