maven发布工程到tomcat

 

第一种是使用内嵌的Tomcat插件

 

   在pom.xml中添加插件:

     <plugin>   
              <groupId>org.codehaus.cargo</groupId>
			        <artifactId>cargo-maven2-plugin</artifactId>
			        <configuration>
			            <container>
			                <containerId>tomcat6x</containerId>
			                <type>remote</type>
			            </container>
				        <configuration>
					        <type>runtime</type>
					        <properties>
					            <cargo.tomcat.manager.url>
					                http://localhost:8080/manager
					            </cargo.tomcat.manager.url>
			  <!-- 这是第一步添加的用户 -->
		      <cargo.remote.username>admin</cargo.remote.username>
	              <cargo.remote.password>admin</cargo.remote.password>
					        </properties>
			        	</configuration>
			            <deployer>
			                <type>remote</type>
			                <deployables>
			                    <deployable>
			                        <groupId>xxx</groupId>
			                        <artifactId>xxx</artifactId>
			                        <type>war</type>
			                    </deployable>
			                </deployables>
			            </deployer>
			        </configuration>
			    </plugin>

 

启动命令:tomcat:run -Dmaven.tomcat.port=80       //端口参数可以省略,默认8080

 

第二种是使用外部的 Tomcat 来启动

 

1右击新建的maven工程,打开工程属性,选中Project  Facets,在右边选中java和Dynamic Web Module(先选java),点击OK,这样,工程就变成一个web工程了。

2打开工程属性,选中左边的Deploymemnt Assemly(web工程才有这个选项)。

3删除Source为/WebContent的那行,该行没用。

4添加web的根目录: Add -> 选中Folder -> Next -> 选中src/main/webapp -> Finish;

5添加依赖包:Add -> 选中Java Build Path Entries -> Next -> 选中Maven Dependencies -> Finish。

6发布到window ->preferences -> server -> runtime environment里的tomcat。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值