使用jetty-maven-plugin运行maven多项目
1.准备工作
org.eclipse.jetty jetty-maven-plugin 9.2.11.v20150529
jdk 1.7
maven 3.1
2.采用maven管理多项目的方式
1> pom工程nemo-pom的pom.xml,这里packaging要声明成pom以使用管理web modules.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>river</groupId>
<artifactId>nemo-pom</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>nemo-pom</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.3.1.RELEASE</spring.version>
<jetty_version>9.2.11.v20150529</jetty_version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty_version}</version>
<exclusions>
<exclusion>
<artifactId>apache-jsp</artifactId>
<groupId>org.mortbay.jasper</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin> <plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty_version}</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<reload>automatic</reload>
<webApp>
<contextPath>/</contextPath>
</webApp>
<httpConnector>
<port>8180</port>
</httpConnector>
<contextHandlers>
<contextHandler
implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<contextPath>/sample</contextPath>
<resourceBase>${basedir}/../sample/target/sample-${project.version}</resourceBase>
</contextHandler>
<contextHandler
implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<contextPath>/samplefront</contextPath>
<resourceBase>${basedir}/../samplefront/target/samplefront-${project.version}</resourceBase>
</contextHandler>
</contextHandlers>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../sample</module>
<module>../samplefront</module>
</modules>
</project>
2>web项目sample的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>river</groupId>
<artifactId>nemo-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../nemo-pom/pom.xml</relativePath>
</parent>
<artifactId>sample</artifactId>
<packaging>war</packaging>
<name>sample</name>
<properties>
<spring.version>4.3.1.RELEASE</spring.version>
</properties>
<dependencies>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
3>web项目samplefront的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>river</groupId>
<artifactId>nemo-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../nemo-pom/pom.xml</relativePath>
</parent>
<artifactId>samplefront</artifactId>
<packaging>war</packaging>
<name>samplefront</name>
<properties>
<spring.version>4.3.1.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
</project>
4>cd进入 pom工程nemo-pom下,执行mvn clean package



现在可以在sample和samplefront两个web modules 的target目录里分别看到sample-0.0.1-SNAPSHOT.war和samplefront-0.0.1-SNAPSHOT.war两上包已经生成.
5>接着执行mvn jetty:run 如下:

可以看到server已经启动,测试地址如下:
http://localhost:8180/sample/index.jsp
http://localhost:8180/samplefront/index.jsp
使用jetty-maven-plugin运行maven多项目的更多相关文章
- Maven配置tomcat和jetty插件来运行项目
针对eclipse中的Run on Server有些情况下并不是那么好操作,比如配置maven下的springmvc插件,如果使用此方法运行会很容易出现组件缺少导致错误出现一大堆的问题. 那么针对这种 ...
- 图文详解 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)
图文详解 IntelliJ IDEA 15 创建 maven 的 Web 项目 搭建 maven 项目结构 1.使用 IntelliJ IDEA 15 新建一个项目. 2.设置 GAV 坐标 3. ...
- eclipse构建及运行maven web项目
1:环境 eclipse indigo, JDK1.6, maven 3.2.1, tomcat7.0.42 2:安装eclipse maven插件 m2eclipse 第一种方法:从网上下载m2ec ...
- 使用maven 命令运行项目
安装好maven3 配置好环境变量后, 输入mvn -v 查看安装是否成功, 然后导入maven项目, 选择import 导入选择Exsting Maven Projects, 接下来就准备运行一下m ...
- eclipse 创建并运行maven web项目
这两天想在eclipse上运行maven web项目,折腾了许久,总算success啦. 1,利用eclipse创建dynamic web project(eclipse需要安装m2eclipse). ...
- 图文具体解释 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)
图文具体解释 IntelliJ IDEA 15 创建 maven 的 Web 项目 搭建 maven 项目结构 1.使用 IntelliJ IDEA 15 新建一个项目. 2.设置 GAV 坐标 3. ...
- idea 创建maven web项目部署在 tomcat maven plugin中
前提:1.安装jdk,多数系统使用jdk1.8.xxx,因此选择下载此版本的居多 2.安装Maven 3.部署到tomcat我们可以有两种方式,一种是利用tomcat插件来进行部署,另一种是下载tom ...
- 解决Jetty Maven Plugin:Please initialize the log4j system properly(转)
解决Jetty Maven Plugin:Please initialize the log4j system properly.Jetty Maven Plugin环境: <plugin> ...
- 如何在Linuxt系统下运行maven项目
如何在Linuxt系统下运行maven项目 我们知道现在利用MAVEN来管理JAVA项目是非常常见的.比如公司一般都有一个自己的MAVEN仓库,通过MAVEN仓库来解决我们的项目依赖,更加方便的构建项 ...
随机推荐
- java 用volatile和不用volatile的区别
在当前的Java内存模型下,线程可以把变量保存在本地内存(比如机器的寄存器)中,而不是直接在主存中进行读写.这就可能造成一个线程在主存中修改了一个变量的值,而另外一个线程还继续使用它在寄存器中的变量值 ...
- EasyUI多选的获取
function deletePRE() { var rows = $('#dg').datagrid('getSelections'); var ids = []; var other_ids = ...
- vs2010+Aspx进行sharepoint2010工作流开发(3) 资料整理
http://www.cnblogs.com/janet/archive/2010/04/24/1719315.html http://www.cnblogs.com/poissonnotes/arc ...
- springboot分环境打包(maven动态选择环境)
分环境打包核心点:spring.profiles.active pom.xml中添加: <profiles> <profile> <id>dev</id> ...
- js:二级联动示例
联动原理 当用户点击省级的下拉选项,选择所在省,下一个下拉选项里的选项,则变成用户选择省下的所有市的信息,不会出现其它省市的信息. 省市数据 把省市数据,保存在js文件中,以json形式保存,以便读取 ...
- X_PU
通俗易懂告诉你CPU/GPU/TPU/NPU...XPU都是些什么鬼?[附把妹秘籍] 2017-10-27 19:54移动芯片/谷歌 作者:iot101君 物联网智库 原创 转载请注明来源和出处 现在 ...
- 兼容多浏览器的网页复制插件(ZeroClipboard)
前言: 常规利用JS编写的网页复制功能是最简单的方法,但是只对IE有效,无法做到兼容其它浏览器,对其他浏览器也就只能弹窗提示用户手动复制了. <script type="text/ja ...
- windows驱动
DriveEntry() 启动 停止 接口函数 驱动程序名 驱动程序版本号 异常处理 是否运行 声明LPOReceive类型的函数 声明函数指针(外部传进来的回调函数) 存放配置字符串 本机IP 串口 ...
- c++之boost share_ptr
转载:https://www.cnblogs.com/welkinwalker/archive/2011/10/20/2218804.html
- easyui-tabs及其内容展示
方案一<div class="easyui-panel"> <div class="easyui-tabs" fit=" ...