使用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仓库来解决我们的项目依赖,更加方便的构建项 ...
随机推荐
- php拓展安装
Yaf安装配置:http://www.laruence.com/manual/yaf.install.html#yaf.installation.linux 下载Yaf的最新版本, 解压缩以后, 进入 ...
- 关于空指针NULL、野指针、通用指针
http://www.cnblogs.com/losesea/archive/2012/11/16/2772590.html 首先说一下什么是指针,只要明白了指针的含义,你就明白null的含义了.假设 ...
- virtualbox Linux与Windows共享文件
安装virtualbox增强功能 在Windows下新建文件用于共享,点设置->共享文件夹->添加共享文件,制定路径和名称(名称用于Linux中挂载使用)(选择固定分配) 在Linux中m ...
- oracle基本查询入门(一)
一.基本select语句 SELECT *|{[DISTINCT] column|expression [alias], ...} FROM table; 例如: --查询所有数据 select * ...
- js无刷新提交表单
$("#form1").attr("target", "frameFile"); $("#form1").submit( ...
- ServiceStack支持跨域提交
//ServiceStack对浏览器有一定的限制 //修改AppHost.cs文件 using Funq;using ServiceStack;using ServiceStackTest.Servi ...
- centos一键安装lnmp成功后无法访问ip(解决办法)
自己搞了个服务器 (我的服务器网络类型是 专有网络)如下图点击 配置规则 进入到 进.出端口规则配置 点击添加安全组规则 如图所配置 添加完成后 就如下面所示 (配置完成后 通过ip就已经可以访问了 ...
- Linux 添加硬盘
一.简介 本文介绍为Linux 添加硬盘的基本方法,同时适用于为虚拟机添加硬盘的情况. 二.添加小于2T的硬盘 1)分区 fdisk /dev/hda 2)建立文件系统 3)设置开机自动挂载磁盘 ...
- PhpStorm 注册相关
网址 http://idea.lanyus.com/ 最新(2017年9月)PhpStorm 2017.3 .WebStorm 2017.2.5.PyCharm 2016.3激活方式 打开网址 ht ...
- mysql添加注释
-- 查看字段类型-- show columns from campaign_distribute --给表添加注释 -- alter table campaign_distribute commen ...