8.Eclipse中创建Maven Web项目
第一步:
创建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项目的更多相关文章
- eclipse 中创建maven web项目
Maven的Eclipse插件m2eclipse在线安装地址 http://m2eclipse.sonatype.org/sites/m2e:我又试了link方式安装也没什么作用,不知怎么回事? 还有 ...
- eclipse中创建maven web项目
本文主要说明将maven web项目转成eclipse支持的web项目. 创建一个maven项目设置打包类型为war则其为web项目 结构如下 将mavenweb项目转成eclipse识别的web项目 ...
- 在eclipse中创建maven webapp项目时弹出错误-解决办法
在eclipse中创建maven webapp项目时报错: Could not resolve archetype org.apache.maven.archetypes:maven-archetyp ...
- IDEA中创建maven web项目
本文将带你一路从IDEA中maven的配置到创建maven web项目,掌握IDEA中maven的使用. 一.IDEA中配置maven 开发中一般我们使用自己下载的maven,不使用IDEA工具自带的 ...
- 在Eclipse中建立Maven Web项目
一.软件版本 Eclipse Java EE IDE for Web Developers. Version: Neon Release (4.6.0) Maven 3.3.9 Servlet 2.5 ...
- Eclipse Oxygen创建maven web项目(一)
1. 首先新建一个maven项目(默认是打包成jar的项目) 也可以建一个war类型的maven项目,反正都需要手动建立一些缺失的文件夹. 2. 修改pom.xml的打包类型参数 默认的jar类型的包 ...
- 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 ...
- Eclipse中导入Maven Web项目并配置其在Tomcat中运行
今天因为实习的关系需要讲公司已经开发的项目导入进Eclipse,而公司的项目是用Maven来构建的所以,需要将Maven项目导入进Eclipse下. 自己因为没有什么经验所以搞了得两个多小时,在这里和 ...
- IDEA中创建maven web项目的详细部署
步骤一:首先先创建一个project,上次我说过了创建一个project就是一个工作空间,在这里就是创建一个maven的工作空间 步骤二:你要选择maven然后按照下面图片 的指示操作就可以了---& ...
随机推荐
- poj1459(最大流)
传送门:Power Network 题意:在一个网络图中有n个点,其中有np个发电站,nc个用户,m条电线;每个发电站,用户,和电线都对应有一个最大的电流;让求出该网络中最大的电流. 分析:最大流裸题 ...
- Android 调用谷歌语音识别
調用谷歌语音识别其实很简单,直接利用 intent 跳转到手机里面的谷歌搜索 代码也很简单,直接调用方法 startVoiceRecognitionActivity() 如果大家手机里面没有谷歌搜索, ...
- 使用WIX打包客户端程序
原文:使用WIX打包客户端程序 用WPF为客户做了个小工具,打包的时候发现VS2012居然没有安装项目了,搜了下才知道现在推荐使用WIX来打包了http://wix.sourceforge.net/, ...
- 32位Linux文件限制大小
线上程序不断重新启动,查看log发现是进程由于SIGXFSZ信号退出.对过大的文件进行操作的时候会产生此信号,一般仅仅在32位机器上出现,文件限制大小为2G.用lsof查看进程打开的文件,果然有一个文 ...
- Android笔记之网络-基本了解
1.3个相关API接口 Android网络编程相关的API接口与相关用途例如以下图 2. 2种网络架构模式 B/S----浏览器/server端模式,通过应用层的HTTP协议通信,不须要特定clien ...
- TypeError: Cannot read property 'style' of null 错误解决
错误信息例如以下: JSP代码例如以下: <c:if test ="${not empty excelErrors}"> <div id="excelE ...
- 第1次实验——NPC问题(回溯算法、聚类分析)
题目:八皇后问题,是一个古老而著名的问题,是回溯算法的典型案例.该问题是国际西洋棋棋手马克斯·贝瑟尔于1848年提出:在8X8格的国际象棋上摆放八个皇后,使其不能互相攻击,即随意两个皇后都不能处于同一 ...
- 安装Python和pip
windows下面安装Python和pip终极教程 在大二的时候接触过一段时间的Python,最近又开始玩起了这门语言.总的来说,个人很喜欢Python的语言风格,但是这门语言对于windows并不算 ...
- Windows Phone开发(45):推送通知大结局——Raw通知
原文:Windows Phone开发(45):推送通知大结局--Raw通知 为什么叫大结局呢?因为推送通知服务就只有三种,前面扯了两种,就剩下一种--Raw通知. 前面我们通过两节的动手实验,相信大家 ...
- iOS Dev (59) 高度自适应的UITextView
iOS Dev (59) 高度自适应的UITextView 作者:阿锐 地址:http://blog.csdn.net/prevention - 例如以下 _inputTextView 为一个 UIT ...