码迷,mamicode.com
首页 > 其他好文 > 详细

Maven实战---插件动态打包

时间:2014-11-30 14:12:20      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   os   sp   java   for   

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

 

        下面说一下在打包的时候遇到的问题:

            Maven在用插件动态打war包的时候出现这样的错误:

[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文件:

<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生命周期的。

Maven实战---插件动态打包

标签:style   blog   http   io   ar   os   sp   java   for   

原文地址:http://blog.csdn.net/liutengteng130/article/details/41622013

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!