第一步:

创建maven webproject

注意以下一步:

第二步:

继承parent

改动pom.xml文件例如以下

<projectxmlns="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>cn.toto.maven</groupId>

<artifactId>web</artifactId>

<packaging>war</packaging>

<name>web Maven Webapp</name>

<url>http://maven.apache.org</url>

<parent>

<groupId>cn.toto.maven</groupId>

<artifactId>Parent</artifactId>

<version>0.0.1-RELEASE</version>

<relativePath>../Parent/pom.xml</relativePath>

</parent>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

</dependency>

<dependency>

<groupId>cn.toto.maven</groupId>

<artifactId>MakeFriends</artifactId>

</dependency>

</dependencies>

</project>

第三步:

建立測试jsp

<%@ page language="java"contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<%@ pageimport="cn.toto.maven.MakeFriends.*"%>

<%

MakeFriendsmakeFriends=new MakeFriends();

out.println(makeFriends.makeFriends("wanglipeng"));

%>

第四步:

自己主动部署到tomcat以下(web项目下的pom.xml中)

<build>

<finalName>web</finalName>

<plugins>

<plugin>

<groupId>org.codehaus.cargo</groupId>

<artifactId>cargo-maven2-plugin</artifactId>

<version>1.2.3</version>

<configuration>

<container>

<containerId>tomcat7x</containerId>

<!—以下是Tomcat在电脑上的位置à

<home>D:/Program Files/ApacheSoftware Foundation/Tomcat 5.0</home>

</container>

<configuration>

<type>existing</type>

<home>D:/Program Files/ApacheSoftware Foundation/Tomcat 5.0</home>

</configuration>

</configuration>

<executions>

<execution>

<id>cargo-run</id>

<phase>install</phase>

<goals>

<goal>run</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

</build>

第五步:

模块聚合

改动parent.pom

Web模块中的完整的pox.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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<artifactId>web</artifactId>

<packaging>war</packaging>

<name>web Maven Webapp</name>

<parent>

<groupId>cn.toto.maven</groupId>

<artifactId>Parent</artifactId>

<version>0.0.1-SNAPSHOT</version>

<relativePath>../Parent/pom.xml</relativePath>

</parent>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

</dependency>

<dependency>

<groupId>cn.toto.maven</groupId>

<artifactId>MakeFriends</artifactId>

</dependency>

</dependencies>

<build>

<finalName>web</finalName>

<plugins>

<plugin>

<groupId>org.codehaus.cargo</groupId>

<artifactId>cargo-maven2-plugin</artifactId>

<version>1.2.3</version>

<configuration>

<container>

<containerId>tomcat7x</containerId>

<!—以下是Tomcat在电脑上的位置à

<home>D:/Program Files/Apache Software Foundation/Tomcat 5.0</home>

</container>

<configuration>

<type>existing</type>

<home>D:/Program Files/Apache Software Foundation/Tomcat 5.0</home>

</configuration>

</configuration>

<executions>

<execution>

<id>cargo-run</id>

<phase>install</phase>

<goals>

<goal>run</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

</build>

</project>

注意:

Parent中的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>

<groupId>cn.toto.maven</groupId>

<artifactId>Parent</artifactId>

<version>0.0.1-SNAPSHOT</version>

<packaging>pom</packaging>

<name>Parent</name>

<url>http://maven.apache.org</url>

<modules>

<module>../Hello</module>

<module>../HelloFriend</module>

<module>../MakeFriends</module>

<module>../web</module>

</modules>

<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<dependencyManagement>

<dependencies>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.9</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>cn.toto.maven</groupId>

<artifactId>HelloFriend</artifactId>

<version>0.0.1-SNAPSHOT</version>

<scope>compile</scope>

</dependency>

<dependency>

<groupId>cn.toto.maven</groupId>

<artifactId>Hello</artifactId>

<version>0.0.1-SNAPSHOT</version>

<scope>compile</scope>

</dependency>

<dependency>

<groupId>cn.toto.maven</groupId>

<artifactId>MakeFriends</artifactId>

<version>0.0.1-SNAPSHOT</version>

<scope>compile</scope>

</dependency>

</dependencies>

</dependencyManagement>

<distributionManagement>

<repository>

<id>releases</id>

<name>Internal Releases</name>

<url>http://localhost:8080/nexus-2.1.2/content/repositories/releases/</url>

</repository>

<snapshotRepository>

<id>snapshots</id>

<name>Internal Snapshots</name>

<url>http://localhost:8080/nexus-2.1.2/content/repositories/snapshots/</url>

</snapshotRepository>

</distributionManagement>

</project>

8.Eclipse中创建Maven Web项目的更多相关文章

  1. eclipse 中创建maven web项目

    Maven的Eclipse插件m2eclipse在线安装地址 http://m2eclipse.sonatype.org/sites/m2e:我又试了link方式安装也没什么作用,不知怎么回事? 还有 ...

  2. eclipse中创建maven web项目

    本文主要说明将maven web项目转成eclipse支持的web项目. 创建一个maven项目设置打包类型为war则其为web项目 结构如下 将mavenweb项目转成eclipse识别的web项目 ...

  3. 在eclipse中创建maven webapp项目时弹出错误-解决办法

    在eclipse中创建maven webapp项目时报错: Could not resolve archetype org.apache.maven.archetypes:maven-archetyp ...

  4. IDEA中创建maven web项目

    本文将带你一路从IDEA中maven的配置到创建maven web项目,掌握IDEA中maven的使用. 一.IDEA中配置maven 开发中一般我们使用自己下载的maven,不使用IDEA工具自带的 ...

  5. 在Eclipse中建立Maven Web项目

    一.软件版本 Eclipse Java EE IDE for Web Developers. Version: Neon Release (4.6.0) Maven 3.3.9 Servlet 2.5 ...

  6. Eclipse Oxygen创建maven web项目(一)

    1. 首先新建一个maven项目(默认是打包成jar的项目) 也可以建一个war类型的maven项目,反正都需要手动建立一些缺失的文件夹. 2. 修改pom.xml的打包类型参数 默认的jar类型的包 ...

  7. Eclipse中新建Maven Web项目报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    在maven web项目中的index.jsp中的错误信息如下: The superclass "javax.servlet.http.HttpServlet" was not f ...

  8. Eclipse中导入Maven Web项目并配置其在Tomcat中运行

    今天因为实习的关系需要讲公司已经开发的项目导入进Eclipse,而公司的项目是用Maven来构建的所以,需要将Maven项目导入进Eclipse下. 自己因为没有什么经验所以搞了得两个多小时,在这里和 ...

  9. IDEA中创建maven web项目的详细部署

    步骤一:首先先创建一个project,上次我说过了创建一个project就是一个工作空间,在这里就是创建一个maven的工作空间 步骤二:你要选择maven然后按照下面图片 的指示操作就可以了---& ...

随机推荐

  1. XHTML学习笔记

    1.每个网页都是在XML声明和DTD之后以一个<html>标记开始,以一个</html>标记结束 这两个标记表明在它们之间的所有文本都是HTML格式,他告诉浏览器如何理解该文档 ...

  2. HTC one/M7电信802d 毒蛇ViperOne2.1.0/高级毒蛇工具/完美root,精简/更多自定义,稳定,流畅ROM

    ROM版本 HTC One/M7 802d ROM作者 雪狼团队·大盛 http://weibo.com/DaShengdd Android版本 Android 4.2.2 创建日期 2013.09. ...

  3. SE 2014年4月2日

    一 描述OSPF协议 LSA(Type 1~5)的名称,始发者以及特点 第一类LSA (router lsa)该类lSA为启动了ospf进程的所有路由器都可以产生,该类LSA主要含有本地路由器的接口状 ...

  4. ps、top 、free查看用户资源信息

      查看root用户的进程信息. 运行命令: ps -u root 查看oracle用户的进程信息. 运行命令: ps -u oracle 若查看现在的资源占用情况,如何呢? 运行命令: top 可以 ...

  5. 控制台打印Hibernate的SQL语句显示绑定参数值

    问题? 使用Hibernate提供的show_sql内置属性true只能输出类似于下面的SQL语句:Hibernate:   insert into user(name,password) value ...

  6. 逆向project第004篇:令计算器程序显示汉字(下)

    一.前言 钩子技术是一项很有有用价值的技术.在Windows下HOOK技术的方法比較多,使用比較灵活,常见的应用层的HOOK方法有Inline HOOK(详见<反病毒攻防研究第012篇:利用In ...

  7. wamp5中的apache不能启动,80端口被占用

    在wamp中apache中的httpd.conf文件中 端口文件设置为8080 #Listen 12.34.56.78:8080Listen 8080

  8. linux解压多个文件

    方法很多种, 根据实际文件类型,位置情况进行变通: 1. for查询:for tar in *.tar.gz; do tar xvf $tar; done2. 列出文件列表,然后xargs 逐一解压: ...

  9. JAVA中各种去除空格

    1. String.trim() trim()是去掉首尾空格 2.str.replace(" ", ""); 去掉所有空格,包括首尾.中间 String str ...

  10. 简单的刷票系统(突破IP限制进行投票) (转)

    前言 相信大家平时肯定会收到朋友发来的链接,打开一看,哦,需要投票.投完票后弹出一个页面(恭喜您,您已经投票成功),再次点击的时候发现,啊哈,您的IP(***.***.***.***)已经投过票了,不 ...