Maven配置jetty和tomcat部署方式

[size=x-large][color=red]Tomcat[/color][/size]:
[url]http://tomcat.apache.org/maven-plugin-2.2/[/url]
命令:[url]http://tomcat.apache.org/maven-plugin-2.2/context-goals.html[/url]
pom.xml
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</pluginManagement>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<username>admin</username>
<password>admin</password>
<path>/dev_cpm</path>
<!-- 改变端口:mvn tomcat:run -Dmaven.tomcat.port=8081, 也可以使用下面配置 -->
<port>8081</port>
<!-- 设定内存 -->
<systemProperties>
<JAVA_OPTS>-Xms256m -Xmx512m -XX:MaxPermSize=256m</JAVA_OPTS>
</systemProperties>
</configuration>
</plugin>
</plugins>
</pluginManagement>

settings.xml
<pluginGroups>
....
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
....
</pluginGroups>

命令:
tomcat6:[url]http://tomcat.apache.org/maven-plugin-2.0/tomcat6-maven-plugin/run-mojo.html[/url]
tomcat7:[url]https://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/run-mojo.html[/url]
[i][color=darkblue][b]
tomcat7:run //最新方式
tomcat:run //以前的方式
[/b][/color][/i]
参数说明:
下面配置也可以类似设置: [color=darkblue]maven.appserver.home =D:/jakarta-tomcat- 5.5.6[/color]
其中:maven.appserver.home用于在发布应用时,把打包的部署文件发布到该项指定的目录中的容器环境
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<!-- or if you want to use tomcat 6.x
<artifactId>tomcat6-maven-plugin</artifactId>
-->
<version>2.2</version>
<configuration>
<!-- http port -->
<port>9090</port>
<!-- application path always starts with /-->
<path>/</path>
<!-- optional path to a context file -->
<contextFile>${tomcatContextXml}</contextFile>
<!-- optional system propoerties you want to add -->
<systemProperties>
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<appserver.home>${project.build.directory}/appserver-home</appserver.home>
<derby.system.home>${project.build.directory}/appserver-base/logs</derby.system.home>
<java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
</systemProperties>
<!-- if you want to use test dependencies rather than only runtime -->
<useTestClasspath>false</useTestClasspath>
<!-- optional if you want to add some extra directories into the classloader -->
<additionalClasspathDirs>
<additionalClasspathDir></additionalClasspathDir>
</additionalClasspathDirs>
</configuration>
<!-- For any extra dependencies needed when running embedded Tomcat (not WAR dependencies) add them below -->
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>\${derbyVersion}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</plugin>



[size=x-large][color=red]jetty: [/color][/size][url]http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin[/url]
Eclipse下通过Maven的Jetty插件运行Web工程的配置,包括启动https [url]http://my.oschina.net/cokolin/blog/409164[/url]
pom.xml
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
<configuration>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
</configuration>
</plugin>

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.3.v20120416</version>
<configuration>
<webApp>
<contextPath>/dev_cpm</contextPath>
</webApp>
</configuration>
</plugin>

或者
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.20</version>
<configuration>
<contextPath>/jbpm5</contextPath>
<!--<webDefaultXml>webdefault.xml</webDefaultXml> -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<scanTargetPatterns>
<scanTargetPattern>
<directory>src/main/webapp/WEB-INF</directory>
<excludes>
<exclude>**/*.jsp</exclude>
</excludes>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</scanTargetPattern>
</scanTargetPatterns>
</configuration>
</plugin>

setting.xml
<profile>
...
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>
</profile>

命令: [i][color=darkblue][b]jetty:run[/b][/color][/i]

[color=red][b]部署方式[/b][/color]
1. 参考 [url]http://www.cnblogs.com/fnng/archive/2011/12/16/2290587.html[/url]
2. 点击工具条的小虫子,然后选择Debug config(调试配置), 或者点击项目右键,Debug as(调试方式)-->选择Debug config(调试配置),选择Maven Build, 然后点右上角创建一个配置,在Goals输入:jetty:run, 这里可以使用多个命令,比如:clean jetty:run。然后点击debug(调试),开始以Debug方式运行工程。下次运行的时候,不用配置,右键或者点工具栏那里的debug,会多出刚才的这个配置,然后直接运行。
3.使用server(服务器) of eclipse的方式运行。参考: [url]http://blog.csdn.net/laoshuisheng/article/details/6420003[/url]

[color=red][b]注意:第2种方式,在包含多Module的时候,很难对代码进行调试,这种情况最好使用的3种。[/b][/color]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值