您的位置:首页 > 其它

多模块下的maven jetty插件配置

2015-09-02 10:22 447 查看
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.kuaidadi.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>

<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: