Maven接触有一阵了,也换上了开源的Eclipse进行熟悉,在使用的过程中也换这个试一下那个尝下鲜,首先使用的是tomcat-maven-plugin,通过这个插件将Web项目部署至Tomcat容器当中以下是具体的配置:
1、在~/.m2/settings.xml中增加如下的Tomcat服务器配置
<server>
<id>TestMaven</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
2、在相应的pom.xml中做如下的配置:
<build>
... ...
<plugins>
... ...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager</url>
<server>TestMaven</server>
<path>/test</path>
</configuration>
</plugin>
</plugins>
</build>
3、运行mvn install即可将项目部署至webapps/test目录下了,具体的可参考网址:http://mojo.codehaus.org/tomcat-maven-plugin/
但是,在使用的过程中,这种方式貌似不能满足需求,因此后面使用的是cargo-maven2-plugin插件,较为灵活的一个Deploy插件,具体配置如比上面的
tomcat-maven-plugin稍微有点儿复杂,部分还有不清楚,先写上以后再慢慢研究,配置如下:
<build>
<plugins>
<plugin>
<!-- 指定插件名称及版本号 -->
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<!-- 插件的Tomcat6.x配置 -->
<configuration>
<wait>true</wait> <!--是否说明,操作start、stop等后续操作必须等前面操作完成才能继续-->
<container> <!-- 容器的配置 -->
<containerId>tomcat6x</containerId> <!-- 指定tomcat版本 -->
<type>installed</type> <!-- 指定类型:standalone, installed等 -->
<home>E:\webServers\apache-tomcat-6.0.32-test</home> <!-- 指定Tomcat的位置,即catalina.home -->
</container>
<configuration> <!-- 具体的配置 -->
<type>existing</type> <!-- 类型,existing:存在 -->
<home>E:\webServers\apache-tomcat-6.0.32-test</home> <!-- Tomcat的位置,即catalina.home -->
<properties> <!-- 配置属性 -->
<cargo.tomcat.manager.url>http://localhost:8080/manager</cargo.tomcat.manager.url> <!-- 管理地址 -->
<cargo.remote.username>tomcat</cargo.remote.username> <!-- Tomcat用户名 -->
<cargo.remote.password>tomcat</cargo.remote.password> <!-- Tomcat密码 -->
<cargo.tomcat.ajp.port>8009</cargo.tomcat.ajp.port> <!-- Ajp端口 -->
</properties>
</configuration>
<deployer> <!-- 部署配置 -->
<type>installed</type> <!-- 类型 -->
<deployables> <!-- 部署设置 -->
<deployable> <!-- 部署的War包名等 -->
<groupId>org.test</groupId>
<artifactId>testwebapp</artifactId>
<type>war</type>
<properties>
<context>testwebapp</context> <!-- 部署路径 -->
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
<executions>
<!-- 执行的动作 -->
<execution>
<id>verify-deployer</id>
<phase>install</phase> <!-- 解析install -->
<goals>
<goal>deployer-deploy</goal>
</goals>
</execution>
<execution>
<id>clean-deployer</id>
<phase>clean</phase>
<goals>
<goal>deployer-undeploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
不详细的解释在XML当中,直接运行mvn install OK!~~
分享到:
相关推荐
解决tomcat8-maven-plugin-3.0-r1655215.jar阿里云同有的问题。放到路径org\apache\tomcat\maven\tomcat8-maven-plugin\3.0-r1655215\就可以了
maven-tomcat-plugin让maven与tomcat配合得很好。它可以把应用部署到Tomcat服务器,也可以把tomcat作为内嵌服务器启动,就像jetty一样。 使用JPDA启动tomcat的远程调试功能。这样就能与eclipse配合起来,轻松地实现...
Maven使用tomcat8-maven-plugin插件
maven-project-info-reports-plugin-2.2.jar
maven-project-info-reports-plugin-2.1.jar
maven-svn-revision-number-plugin-1.7.jar 资源共享,有需要其他jar包的可以在评论留言,看到后我会陆续上传。
maven-jar-plugin-3.1.1.jar
maven-resources-plugin-2.4.1.jar
maven-deploy-plugin-2.8.2.jar
maven-deploy-plugin-2.7.jar
maven-site-plugin-3.3.jar
在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/ central junit junit Address/ ...
maven-notice-plugin-1.0.1.jar
maven-plugin-parameter-documenter-2.0.jar
maven-antrun-plugin-3.0.0.jar
maven是个项目管理工具,如果我们不告诉它我们的代码要使用什么样的jdk版本编译的话,它就会用maven-compiler-plugin默认的jdk版本来进行处理,这样就容易出现版本不匹配,以至于可能导致编译不通过的问题。...
maven-install-plugin-2.5.2.jar
maven-maven-plugin-1.4-sources.jar
修改版tomcat7-maven-plugin-2.2.jar
maven-jxr-plugin-2.0.jar