多模块下的maven jetty插件配置

1. 首先你要学会单模块的jetty插件配置.

        网上都是老的

   maven-jetty-plugin
      http://www.cnblogs.com/fnng/archive/2011/12/16/2290587.html 

   现在已经迁移到 jetty-maven-plugin

   但是有些配置不一样了.

2. 后面就是配置多模块的jetty插件了.

       2.1 直接在parent的pom里添加jetty配置,执行mvn jetty:run 的时候会报无法找到 jetty的错误

[ERROR] No plugin found for prefix 'jetty' in the current project and in the plu
gin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repo
sitories [local (C:\Users\admin\.m2\repository), public (http://maven. .c
om/content/groups/public/), central (http://repo.maven.apache.org/maven2)] -> [H
elp 1]

   2.2 经过搜索,搜索到了stackOverflow的一个帖子 

http://stackoverflow.com/questions/3636493/multi-module-maven-project-and-jettyrun

      2.2.1  要搞一个profile

      2.2.2 一定要放在war 模块的pom里.

      2.2.3 删除了stackOverFlow里的webAppSourceDirectory ,因为一旦配了就会导致  mybatis的同一个xml被加载两次,同一个class有两个地方的冲突

      2.2.4   增加了web.xml的指定 ,因为这个web.xml有占位符需要被替换. 默认的src/main/webApp里的有占位符会导致服务不可用.                  <descriptor>${project.basedir}/target\daijia_finance-1.0.3\WEB-INF/web.xml</descriptor> 

      2.2.5 先到 parent 上
mvn clean install
     2.2.6 cd 到  war 所在 目录下 mvn jetty:run
          再parent 上跑,会在第一个jar上就跑了 jetty.

详细如下:

<profile>

                    <id>jetty-run</id>

                    <activation>

                           <activeByDefault>true</activeByDefault>

                    </activation>

                    <properties>

                           <profile.name>dev</profile.name>

                    </properties>

                    <build>

     <plugins>

       <plugin>

          <groupId>org.eclipse.jetty</groupId>

               <artifactId>jetty-maven-plugin</artifactId>

               <version>9.0.0.M5</version>

         <configuration>

           

                     <!--      <webAppSourceDirectory>target\daijia_finance-1.0.3\</webAppSourceDirectory>

                    不能包含WEB-INF\${project.basedir}/  这句不能配,一旦配了就会导致 class 冲突的问题. mybatis的同一个xml被加载两次. 一个是maven 库, 一个是webAppSourceDirectory下的lib路径下  -->

 

                    <webAppConfig> 

                                    <contextPath>/</contextPath>

                                     <descriptor>${project.basedir}/target\daijia_finance-1.0.3\WEB-INF/web.xml</descriptor>

                                    <!-- <extraClasspath>target/daijia_finance-1.0.3\WEB-INF\classes;target\daijia_finance-1.0.3\WEB-INF\lib</extraClasspath>

                                       <baseResourceimplementation="org.eclipse.jetty.util.resource.ResourceCollection">

<resourcesAsCSV>${project.basedir}/target\daijia_finance-1.0.3\</resourcesAsCSV></baseResource> -->

           </webAppConfig>

                    <!--<classesDirectory>  D:\svn_project\finace\daijia_finance\target\daijia_finance-1.0.3\WEB-INF\classes</classesDirectory>-->

         </configuration>

         <executions>

           <execution>

             <id>jetty-run</id>

             <phase>prepare-package</phase>

<!-- process-classes 生命周期即可 mvn clean prepare-package -Pjetty-run -->

             <goals>

               <goal>run</goal>

             </goals>

           </execution>

         </executions>

       </plugin>

     </plugins>

   </build>

             </profile>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值