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多项目的更多相关文章

  1. Maven配置tomcat和jetty插件来运行项目

    针对eclipse中的Run on Server有些情况下并不是那么好操作,比如配置maven下的springmvc插件,如果使用此方法运行会很容易出现组件缺少导致错误出现一大堆的问题. 那么针对这种 ...

  2. 图文详解 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)

    图文详解 IntelliJ IDEA 15 创建 maven 的 Web 项目 搭建 maven 项目结构 1.使用 IntelliJ IDEA 15 新建一个项目.  2.设置 GAV 坐标  3. ...

  3. eclipse构建及运行maven web项目

    1:环境 eclipse indigo, JDK1.6, maven 3.2.1, tomcat7.0.42 2:安装eclipse maven插件 m2eclipse 第一种方法:从网上下载m2ec ...

  4. 使用maven 命令运行项目

    安装好maven3 配置好环境变量后, 输入mvn -v 查看安装是否成功, 然后导入maven项目, 选择import 导入选择Exsting Maven Projects, 接下来就准备运行一下m ...

  5. eclipse 创建并运行maven web项目

    这两天想在eclipse上运行maven web项目,折腾了许久,总算success啦. 1,利用eclipse创建dynamic web project(eclipse需要安装m2eclipse). ...

  6. 图文具体解释 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)

    图文具体解释 IntelliJ IDEA 15 创建 maven 的 Web 项目 搭建 maven 项目结构 1.使用 IntelliJ IDEA 15 新建一个项目. 2.设置 GAV 坐标 3. ...

  7. idea 创建maven web项目部署在 tomcat maven plugin中

    前提:1.安装jdk,多数系统使用jdk1.8.xxx,因此选择下载此版本的居多 2.安装Maven 3.部署到tomcat我们可以有两种方式,一种是利用tomcat插件来进行部署,另一种是下载tom ...

  8. 解决Jetty Maven Plugin:Please initialize the log4j system properly(转)

    解决Jetty Maven Plugin:Please initialize the log4j system properly.Jetty Maven Plugin环境: <plugin> ...

  9. 如何在Linuxt系统下运行maven项目

    如何在Linuxt系统下运行maven项目 我们知道现在利用MAVEN来管理JAVA项目是非常常见的.比如公司一般都有一个自己的MAVEN仓库,通过MAVEN仓库来解决我们的项目依赖,更加方便的构建项 ...

随机推荐

  1. mysql中树形结构表的操作

    一种是:邻接表模型(局限性:对于层次结构中的每个级别,您需要一个自联接,并且随着连接的复杂性增加,每个级别的性能自然会降低.在纯SQL中使用邻接列表模型充其量是困难的.在能够看到类别的完整路径之前,我 ...

  2. sshd_config优化

     sshd_config优化linux系统调优,参考百度搜索  linux ssh命令  /etc/init.d/sshd restart    重启ssh  193  ls  194  vim /e ...

  3. 破解版ps

    http://www.sdifen.com/adobe-photoshop-cc.html

  4. STL容器的常用用法

    STL: 1.vector: vector<int> v;vector<int> v(10);//定义大小为10的int型向量容器.vector<int> v(10 ...

  5. 91. Decode Ways (Array; DP)

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

  6. 3sum, 3sum closest

    [抄题]: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find ...

  7. 批量MD5命名文件

    #coding=utf-8 import os import hashlib def GetFileMd5(filename): if not os.path.isfile(filename): pr ...

  8. jdeveloper基础教程(中文版)

    jdeveloper基础教程(中文版) 程序员的基础教程:菜鸟程序员

  9. 一句话引发的思考 - synchronized/super

    https://blog.csdn.net/cool__wang/article/details/52459380#commentBox

  10. struts2值栈ValueStack中都有哪些东西?

    com.opensymphony.xwork2.dispatcher.HttpServletRequest application com.opensymphony.xwork2.dispatcher ...