maven 采用 maven 3.0以上的版本。tomcat 采用 tomcat 7.0 以上的版本

1. tomcat 配置用户账号和权限

tomcat-users.xml

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

创建其他的role貌似不行,因为你访问http://ip:8080/manager/html然后弹出输入框需要用户名和密码,随意输入一个就会有403访问权限受限制的页面,在这个页面里面定义这个四个role.

修改完成以后记得重启tomcat

项目的设置,在pom.xml需要引入针对tomcat7的plugin

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://192.168.0.51:8081/manager/text</url>
<update>true</update>
<server>servername</server>
<username>admin</username>
<password>admin</password>
<path>/info</path>
</configuration>
</plugin>

在url可以配置本地或者远程的TOMCAT 
path就是在部署上去以后在http://ip:8080/manager/html里面看到部署结果 
server就是一个名字和你maven的settings.xml对应的id一致 

 

2. maven 配置 tomcat 账号

setting.xml 文件

<servers>
<server>
<id>servername</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
 

3. 项目 pom.xml 配置

3.1 build 配置节配置 tomcat 发布插件,注意 server 必须与2中一致,增加update 配置项,更新发布的文件,

tomcat 的发布路径为 http://serverip:port/manager/text

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://192.168.0.51:8081/manager/text</url>
<update>true</update>
<server>servername</server>
<username>admin</username>
<password>admin</password>
<path>/info</path>
</configuration>
</plugin>

3.2 build 配置节配置部署时测试相关,忽略测试

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>

buid下所有插件例子

                <plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<phase>compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/WEB-INF/lib</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<!--<groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version> -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>http://192.168.0.51:8081/manager/text</url>
<update>true</update>
<server>booksair</server>
<username>admin</username>
<password>admin</password>
<path>/info</path>
</configuration>
</plugin>
</plugins>

4. jenkins 项目配置

jenkins mavne goal目标为(针对tomcat 7)clean install tomcat7:deploy

tomcat 配置

WAR/EAR files:**/site.war

tomcat url: http://serverip:port/

(这里不用配置项目路径 或者 manager 路径,否则会出现 Unkown /manager/text/list 错误)

最新文章

  1. C#语言之“中英文混合字符串对齐”的方法
  2. 详解web.xml中元素的加载顺序
  3. log4j日志不输出MyBatis SQL脚本?
  4. 不用安装Oracle_Client就能使用PLSQL_Developer
  5. Nodejs异步异常处理domain
  6. 音频(3)Android TTS技术支持朗读英文
  7. 普通pc电脑安装苹果系统mac_详细教程(精)附带所有工具下载
  8. (转载)mysql书籍
  9. 【转】iOS- 详解文本属性Attributes
  10. StudentSchema student实例数据库环境搭建
  11. springboot~maven制作底层公用库
  12. 添加一个Button按钮
  13. 怎样监听vue.js中v-for全部渲染完成?
  14. Web开发人员vs网页设计师
  15. php 数组数字 补零
  16. [development][PCRE] old PCRE
  17. MySQL数据类型--与MySQL零距离接触2-13MySQL唯一约束
  18. Oracle Statistic 统计信息 小结
  19. 利用BlockingCollection实现生产者和消费者队列,实现写文本
  20. html-注册邮箱

热门文章

  1. NHibernate3剖析:Mapping篇之ConfORM实战(1):概览
  2. Chrome自带恐龙小游戏的源码研究(二)
  3. 【设计模式】C++单例模式的几种写法——Java自动加载内部类对象,C++怎么破?
  4. Mysql 免密码登录,修改密码及忘记密码操作
  5. 【BZOJ4240】有趣的家庭菜园 树状数组+贪心
  6. EasyPlayerPro(Windows)流媒体播放器开发之跨语言调用
  7. 配置springMVC时出现的问题
  8. 九度OJ 1167:数组排序 (排序)
  9. 九度OJ 1149:子串计算 (计数、排序)
  10. GIT / SVN 提交代码时, 注释该怎么写