maven 插件动态打包

  • 插件动态打包
maven把项目的构建划分为不同的生命周期(lifecycle),这个过程包括:编译、测试、打包、集成测试、验证、部署。maven中所有的执行动作(goal)都需要指明自己在这个过程中的执行位置,然后maven执行的时候,就依照过程的发展依次调用这些goal进行各种处理。

下面说一下在打包的时候遇到的问题:  Maven在用插件动态打war包的时候出现这样的错误:
[java] view plaincopyprint?在CODE上查看代码片派生到我的代码片
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.5:war (default-war) on project MavenProj1: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]  
    [ERROR]   
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.  
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.  
    [ERROR]    
    [ERROR] For more information about the errors and possible solutions, please read the following articles:  
    [ERROR] [Help 1] https://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException  

 意思是说构建项目的时候没有找到web.xml文件,通常我们建的Maven项目的根目录为webapp,现在我们改为webContent文件夹,所以我们需要指定网站的根目录。

目录:
webapp            
   │—  pom.xml           
   │            
   └─src           

       └─main            
           ├─resources            
           └─webapp            
               │ index.jsp           
               │            
               └─WEB-INF            
                    web.xml
修改pom文件:
[java] view plaincopyprint?在CODE上查看代码片派生到我的代码片

    <build>  
        <finalName>gx</finalName>  
        <plugins>  
            <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-war-plugin</artifactId>  
                <version>2.5</version>                      
                <configuration>  
                    <!--指定web.xml文件的位置,这是一种方式-->  
                    <webXml>WebContent\WEB-INF\web.xml</webXml>  
                <!--指定目录位置,这是另一种方式,可以把本目录下所有的xml文件都打到Jar包中-->  
                  <!--<webResources>  
                        <resource>  
                            <directory>webContent</directory>  
                         </resource>  
                 </webResources>-->  
                </configuration>  
            </plugin>  
        </plugins>  
    </build>  

这些东西都是我们构建Maven项目必不可少的,这部分主要用到的是Maven插件机制,Maven的插件机制是依赖于Maven生命周期的。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值