多模块下的maven jetty插件配置
2015-09-02 10:22
447 查看
1. 首先你要学会单模块的jetty插件配置.
网上都是老的
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>
网上都是老的
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>
相关文章推荐
- Matlab数据处理常用命令整理
- 如何惊呆你的面试官-程序员面试
- XListView源码分析
- 明天, 我就要走
- 84 XML解析
- Linux 解压
- CSS实现底部固定
- CentOS7 apache
- Android studio
- Java简单实现SpringMVC+MyBatis分页插件
- STM32F4——TFT-LCD原理及FSMC
- U-boot-2014.04移植到MINI2440(8) nand flash 读写支持移植
- 关于事件的小结
- C语言中改变目录的相关操作函数详解
- 格力空调遥控器红外编码透析(长码)
- objective-c基础教程——学习小结
- Tomcat中server.xml文件内各节点详解
- 【内存泄露/C++】基于重载new运算符的内存泄露检测工具
- UVA 11374 Airport Express (最短路)
- caffe-将图片转化为siamese网络需要的数据库格式