惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
B
Blog
F
Fortinet All Blogs
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
A
About on SuperTechFans
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
B
Blog RSS Feed

博客园 - sleepy

Android 下进行单元测试 Test run failed:Instrumentation run failed due to 'java.lang.ClassNotFoundException' windows 7下命令行修改用户密码 VMWare Workstation 中Guest OS使用Bridge方式上网故障诊断 CSS guideline java下运行windows命令行程序(批处理文件)示例 - sleepy - 博客园 不用安装Oracle Client如何使用PLSQL Developer 新的 好用的 免费的 功能强大的Oracle 客户端 MySQl客户端访问软件 VPC 2007 SP1下安装Windows虚拟机要点(关键字:VM,Virtual PC, 网络,共享文件,windows 2003, vista, Window XP) tomcat 设置初始内存大小(默认的可是太小了,容易内存溢出) - sleepy - 博客园 测试显示内存使用情况的JSP脚本 在Virtual PC 2007 SP1上安装linux ubuntu 810 如何解决eclipse编辑器,console 汉字显示为乱码?? MySQL内置命令导出数据库 iBatis 数据库空值的映射处理 设置MySQL 超时等待时间 Java中访问My SQL如何显示SQL中的汉字 如何高效率修改bug 如何在MySql中记录SQL日志(例如Sql Server Profiler)
使用Maven自动部署Tomcat 6和Tomcat 7下Web应用
sleepy · 2014-03-28 · via 博客园 - sleepy

使用Maven自动部署Tomcat 6和Tomcat 7下Web应用

  1. 开启Tomcat远程管理权限

在tomcat的config目录下的tomcat-users.xml文件,

<role rolename="manager-gui"/>

<role rolename="manager-script"/>

<role rolename="manager-jmx"/>

<role rolename="manager-status"/> 

<role rolename="admin-gui"/> 

<role rolename="admin-script"/> 

<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

不多说,此处多给些权限,别小气,否则容易没有权限进行部署(tomcat给的原始配置示例都被<!---->注释掉了)。配置是否成功的验证方法是重启Tomcatà登陆tomcat管理控制台à输入用户名密码后(admin/admin)à部署一个war应用试试,成功则OK,不成功就不要往下走了。

  1. 配置tomcat6-maven-plugintomcat7-maven-plugin

工程POM中,配置插件:

Tomcat 6的配置示例如下:

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat6-maven-plugin</artifactId>

<version>2.2</version>

<configuration>

<url>http://16.158.165.0:8080/manager</url><!-- http://127.0.0.1:8080/manager-->

<username>admin</username>

<password>admin</password>

<path>/BizService</path><!--WEB应用上下文路径-->

</configuration>

</plugin>

Tomcat 7的配置示例如下:(注意红色高亮部分差异)

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat7-maven-plugin</artifactId>

<version>2.2</version>

<configuration>

<url>http://16.158.165.0:8080/manager/text</url>

<username>admin</username>

<password>admin</password>

<path>/BizService</path><!--WEB应用上下文路径-->

</configuration>

</plugin>

  1. 部署相关命令

Tomcat 6部署及重新部署命令

mvn tomcat6:deploy

mvn tomcat6:redeploy

Tomcat 7部署及重新部署命令

mvn tomcat7:deploy

mvn tomcat7:redeploy

  1. 备注

m2eclipse也是如此配置。

<username><password>也可以用<server>方式配置,就是在setting文件中配置用户名密码,POM中只是指定server id,此处不详述。

  1. 详细信息(来自官网2.3版本)

Goal

Description

tomcat6:deploy

Deploy a WAR to Tomcat.

tomcat6:deploy-only

Deploy a WAR to Tomcat without forking the package lifecycle.

tomcat6:exploded

Deploy an exploded WAR to Tomcat.

tomcat6:help

Display help information on tomcat6-maven-plugin.
Call mvn tomcat6:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

tomcat6:info

Lists information about the Tomcat version, OS, and JVM properties.

tomcat6:inplace

Deploy a WAR in-place to Tomcat.

tomcat6:list

Lists all the currently deployed web applications in Tomcat.

tomcat6:redeploy

Redeploy a WAR in Tomcat. (Alias for the deploy goal with its update parameter set to true.)

tomcat6:redeploy-only

Redeploy a WAR in Tomcat without forking the package lifecycle. (Alias for the deploy-only goal with its update parameter set to true.)

tomcat6:reload

Reload a WAR in Tomcat.

tomcat6:resources

Lists JNDI resources in Tomcat.

tomcat6:roles

Lists security roles in Tomcat.

tomcat6:run

Runs the current project as a dynamic web application using an embedded Tomcat server.

tomcat6:run-war

Runs the current project as a packaged web application using an embedded Tomcat server.

tomcat6:run-war-only

Same as run-war goal without forking the package cycle.

tomcat6:sessions

Lists session information for a WAR in Tomcat.

tomcat6:shutdown

Shuts down all possibly started embedded Tomcat servers. This will be automatically done through a shutdown hook or you may call this Mojo to shut them down explictly.

By default the shutdown goal is not bound to any phase. For integration tests you might want to bind it topost-integration-test.

tomcat6:start

Start a WAR in Tomcat.

tomcat6:stop

Stop a WAR in Tomcat.

tomcat6:undeploy

Undeploy a WAR from Tomcat.