maven+tomcat7配置

maven+tomcat7配置

tomcat7配置

首先打开tomcat安装目录中的conf/tomcat-users.xml,在内部添加如下代码

<role rolename="manager-gui"/>    
<role rolename="manager-script"/>    
<user username="xxxx" password="xxxxx" roles="manager-gui, manager-script"/>    

maven配置

在maven的安装目录中的conf文件夹中有settings.xml,或者在maven仓库中有settings.xml,打开该xml文件,在内部添加如下代码:

<server>
 <id>tomcat</id>
 <username>xxxx</username>
 <password>xxxx</password>
</server>

注意

  1. 这里的id可以随便取名,但是注意要与pom.xml文件中的id相同,maven根据这个id找到相应的服务器将项目部署上去。
  2. username为上述tomcat的tomcat-users.xml中新增user的username。
  3. password为上述tomcat的tomcat-user.xml中新增user的password。

项目中pom.xml配置

pom.xml需要增加tomcat-maven-plugin插件,代码如下所示:

 <plugins>  
            <plugin>  
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId> 
                <version>2.2</version>               
                <configuration>  
                         <server>tomcat</server>
                         <url>http://localhost:8080/manager/text</url>              
                </configuration>  
            </plugin>  
 </plugins>  

注意:

  1. <server>tomcat</server>中tomcat就是在上述的maven配置中<id>tomcat</id>
  2. <url>........../text</url>注意tomcat7必须以text结尾
  3. maven命令要以tomcat7开头,例如tomcat7:deploy,tomcat7:redeploy
  4. 注意该插件的groupid和artifactid:
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId> 

将其与老版本的tomcat-maven插件区别开来,即:

<groupId>org.codehaus.mojo</groupId>                
<artifactId>tomcat-maven-plugin</artifactId>

新版本的tomcat-maven-plugin支持tomcat6和tomcat7,两者区别如下:

  <groupId>org.apache.tomcat.maven</groupId>  
  <artifactId>tomcat6-maven-plugin</artifactId>  

  <groupId>org.apache.tomcat.maven</groupId>  
  <artifactId>tomcat7-maven-plugin</artifactId>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值