maven发布项目到本地tomcat

来源:互联网 发布:网络销售文人字画 编辑:程序博客网 时间:2024/06/02 02:03

添加plugin:

                       <plugin><!-- 使用maven的tomcat插件打包并部署war文件到tomcat --><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.0</version><configuration>    <path>/${project.build.finalName}</path>  <url>http://localhost:8080/manager/text</url><server>tomcat</server><username>tomcat</username><password>password</password></configuration></plugin><plugin><!-- 这里版本为1.7 请注意编译版本 否则会报错 --><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>1.7</source><target>1.7</target><encoding>${project.build.sourceEncoding}</encoding></configuration></plugin>
其中用户名和密码的配置可以理解为maven为了和本地tomcat打交道而由tomcat的配置的口令,首先要在tomcat安装目录下conf文件夹下的tomcat-users.xml文件中配置:

<tomcat-users><!--  NOTE:  By default, no user is included in the "manager-gui" role required  to operate the "/manager/html" web application.  If you wish to use this app,  you must define such a user - the username and password are arbitrary.--><!--  NOTE:  The sample user and role entries below are wrapped in a comment  and thus are ignored when reading this file. Do not forget to remove  <!.. ..> that surrounds them.-->    <!-- maven发布到tomcat -->   <role rolename="manager-gui"/>       <role rolename="manager-script"/>       <user username="tomcat" password="password" roles="manager-gui, manager-script"/>  </tomcat-users>

这里配置好后,启动tomcat,在浏览器输入localhost:8080/manage会让你输入用户名密码,输入这里配置的用户名/密码,若验证通过会跳到tomcat web application Manager页面,就说明该配置是成功的,就可以往下进行;若验证不通过,会跳到一个说明页面,里面有对各role的说明(想了解上面role的童鞋请自行查看),此时再修改配置,直至验证成功。



<servers>    <!-- server     | Specifies the authentication information to use when connecting to a particular server, identified by     | a unique name within the system (referred to by the 'id' attribute below).     |     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are     |       used together.     |    <server>      <id>deploymentRepo</id>      <username>repouser</username>      <password>repopwd</password>    </server>    -->    <server>          <id>tomcat</id>          <username>tomcat</username>          <password>password</password>      </server>   </servers>
配置maven的settings.xml文件,至于settings.xml文件在你机器的哪里,请自行查找。这里的用户名和密码都与tomcat-users.xml中验证通过的用户名密码一致,这里的‘id’要与pom文件的<server>tomcat</server>一致,当然pom文件的用户名和密码也要对应。

共有三处进行了用户名密码配置。


选择eclipse的绿色启动按钮的下拉列表的run configurations...,新增一个maven指令“tomcat7:deploy”,运行指令前先启动tomcat,

不出意外就发布成功。



0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 年检标志跟车牌号不一样怎么办 纹完身后喝酒了怎么办 孩子学习态度不端正怎么办 孩子高考三模考差了家长怎么办 一年级学生学习马虎大意怎么办 一年级下册孩子做作业马虎怎么办 一年级孩子做题马虎怎么办 四年级小孩不喜欢数学该怎么办 工作出了大错误怎么办 遇到不讲道理的人怎么办 四岁宝宝爱生闷气怎么办 一岁宝宝没耐心怎么办 孩子挑食 幼儿园老师该怎么办 小孩被惯的无法无天怎么办 高中的儿子不写作业怎么办 儿子总是不写作业怎么办 长鸡眼脚背肿了怎么办 脚上反复长鸡眼怎么办 脚底长鸡眼很痒怎么办 小脚趾上长鸡眼怎么办 6岁宝宝不爱学习怎么办 上班站久了腿肿怎么办 站时间长了腿肿怎么办 孩子做作业老是粗心大意怎么办 高中孩子没学习兴趣怎么办 初三孩子失去学习兴趣怎么办 初二对学习兴趣不大怎么办 脸上痒发红发肿怎么办 孩子作业拖拉爱丢三落四怎么办 腿肌肉按摩肿了怎么办 孩子上一年级成绩差怎么办 小孩脖子拧筋了怎么办 小孩塑料玩具拧不出来怎么办 一年级孩子做数学题粗心怎么办 手和脚有点肿怎么办 手破了之后肿了怎么办 手指肿了有脓怎么办 宝宝手指红肿有脓怎么办 孩子一听做作业就烦气怎么办 虎皮鹦鹉脚瘸了怎么办 虎皮鹦鹉脚受伤了怎么办