Myeclipse 创建 Web Maven项目
1、创建Web项目
添加Maven支持

2、pom.xml 报如下错误:

解决办法:
pom.xml里面添加依赖:
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.7</version>
</dependency>
重启Myeclipse, 在项目上 右键->maven4Myeclipse->update project Configrotion->勾选force update of……即可;
3、补全目录
项目右击-> new -> source folder 建立如下目录结构 resources下面一般放配置文件;

4、修改一下 index.jsp文件,改为 Hello Maven!
5、部署 在server视图中 点击如下按钮

6、启动项目,在浏览器中输入:http://localhost:8080/helloMaven/ 即可!

7、下面的开发工作与Web开发大体相同,区别在于以下两点:
① 引入jar包时,不需要收工引入,在pom.xml添加依赖即可
② 测试相关的放在test目录下,代码相关的放在Java目录下,配置相关的放在resource下面
8、一个简单示例项目结构如下:


9、下面介绍一些常用的命令
Maven test --运行项目中的测试代码,在正式运行之前,可能需要下载很多其他文件,需要等待一些时间

Maven build... ---执行Maven命令,在弹出的对话框中 的Goals里面输入要执行的命令,点击run即可执行命令。

Maven install ------将项目输出构件部署到本地仓库
Maven clean ------将target里面的class类清除,但配置文件不会清除
myeclipse中执行Maven命令:
选择 Maven build ...... 点击select

10.Maven 远程发布到中央仓库
首先配置鉴权(安全认证),在本地setting.xml文件的servers标签下面添加:
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
其中:id 是仓库名,使用username和userpassword登录后,点击左侧的Repositories即可看到;

项目配置,修改pom.xml文件
<distributionManagement>
<repository>
<id>releases</id> <!-- 与setting.xml中的server id对应 -->
<name>panteng_release</name>
<!-- 此URL在Repositories可以看到 -->
<url>http://192.168.63.133:9434/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
run - build... - deploy命令即可;
如果返回401 一般是用户权限设置错误,在setting.xml中配置用户权限
返回400 可能是不允许部署,进行如下操作:

或者可能是pom.xml中的version标签包含了 0.0.1-SNAPSHOT,把 -SNAPSHOT去掉即可(http://www.codeweblog.com/maven-deploy-return-code-is-400)
<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>com.hi19pay.comm.ctp</groupId>
<artifactId>demo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging> <name>demo-parent</name>
<description>19pay comm demo-parent project</description> <licenses>
<license>
<name>19pay CTPI parent</name>
<url>http://www.19pay.com.cn</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses> <organization>
<name>hi19pay</name>
<url>http://www.19pay.com.cn</url>
</organization> <developers>
<developer>
<name>jiangzx</name>
<organization>hi19pay</organization>
<organizationUrl>//www.19pay.com.cn</organizationUrl>
<roles>
<role>comm developer</role>
</roles>
<email>jiangzx@19pay.com.cn</email>
</developer>
</developers> <modules>
<module>demo-util</module>
<module>demo-entity</module>
<module>demo-dao</module>
<module>demo-service</module>
<module>demo-web</module>
</modules> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springversion>3.0.1.RELEASE-A</springversion>
<junitversion>4.12</junitversion>
</properties> <build>
<pluginManagement>
<plugins>
<!-- 编译源代码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<!-- 指定外部lib路径 -->
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin> <!-- 打包源代码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin> <!-- 生成javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<aggregate>true</aggregate> <!-- 多模块工程中,将javadoc集中到父工程 -->
<encoding>UTF-8</encoding>
</configuration>
</plugin> <!-- Test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<skipTests>true</skipTests> <!-- 打包过程忽略Junit测试 -->
</configuration>
</plugin> <!-- 将外部lib一起打成war包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin> <!-- 生成manifest文件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath> <!-- 依赖的jar-->
</manifest>
</archive>
</configuration>
</plugin> <!-- mybatis代码生成工具 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose> <!--允许移动生成的文件-->
<overwrite>true</overwrite> <!--允许覆盖生成的文件-->
</configuration>
</plugin> </plugins>
</pluginManagement>
</build> <distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://192.168.63.133:9434/nexus/content/repositories/releases/
</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://192.168.63.133:9434/nexus/content/repositories/snapshots/
</url>
</snapshotRepository>
</distributionManagement> <dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency> <dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency> <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency> <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junitversion}</version>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency> <!-- Apache Commons Codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency> <dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
多模块企业级项目配置实例 pom.xml
Myeclipse 创建 Web Maven项目的更多相关文章
- IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)
Eclipse用多了,IntelliJ中创建Maven聚合项目可能有小伙伴还不太熟悉,我们今天就来看看. IntelliJ中创建普通的Java聚合项目相对来说比较容易,不会涉及到web操作,涉及到we ...
- 38.IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)
转自:https://blog.csdn.net/u012702547/article/details/77431765 Eclipse用多了,IntelliJ中创建Maven聚合项目可能有小伙伴还不 ...
- maven命令创建web骨架项目
maven命令创建web骨架项目有以下两种方式: mvn archetype:create -DgroupId=org.seckill -DartifactId=seckill -Darchetype ...
- IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)(转载)
创建parent项目 1.打开IDEA,注意这里不要勾选模板,用模板创建过maven项目的小伙伴都知道模板创建项目非常慢,所以这里不要选模板,需要的文件夹我们后面自己来创建就可以了.所以这个页面直接点 ...
- maven系列之二maven项目的创建和maven项目的结构
maven系列之一简单介绍了maven的基本信息,安装和配置,大家对maven有一个大概的了解,但是在maven项目开发中远远不够,为了进一步了解maven,现在我们介绍maven项目的创建和mave ...
- eclipse中创建一个maven项目
1.什么是Maven Apache Maven 是一个项目管理和整合工具.基于工程对象模型(POM)的概念,通过一个中央信息管理模块,Maven 能够管理项目的构建.报告和文档. Maven工程结构和 ...
- 使用Intellij Idea创建简单Maven项目(转)
我是学Java Web的,基本靠自学,在网上收集了各种视频资料,逐一的看,代码逐一的敲.学习了这么久之前一直未成想过要把自己的学习路程记录下来,在网上也看到过很多人把自己的学习历程以及遇到的问题写在了 ...
- eclipse 创建聚合maven项目
本人不想花太多时间去排版,所以这里排版假设不好看,请多多包涵! 一直都在用maven,可是却基本没有自己创建过maven项目,今天也试着创建一个. 1.打开eclipse.然后new,other,然后 ...
- Maven(一)如何用Eclipse创建一个Maven项目
1.什么是Maven Apache Maven 是一个项目管理和整合工具.基于工程对象模型(POM)的概念,通过一个中央信息管理模块,Maven 能够管理项目的构建.报告和文档. Maven工程结构和 ...
随机推荐
- linux反弹shell
参考链接 http://www.cnblogs.com/r00tgrok/p/reverse_shell_cheatsheet.html http://www.waitalone.cn/linux-s ...
- 【LeetCode】462. Minimum Moves to Equal Array Elements II
Given a non-empty integer array, find the minimum number of moves required to make all array element ...
- html5存储相关 coookie localstorage session storage
html5存储 coookie localstorage session storage
- VC中获取窗口控件相对客户区的坐标
1: RECT rect; 2: GetDlgItem(item_id).GetWindowRect(&rect); 3: ScreenToClient(&rect);
- 2015 Multi-University Training Contest 9
1001 Expression 式子不好推啊.见官方题解. 式子知道就方便了.处理好组合数和阶乘. 按区间长度从小到大递推完就好. # include <iostream> # inclu ...
- 一个初学者的辛酸路程-了解Python-2
前言 blog花了一上午写的,结果笔记本关机了,没有保存,找不到了,找不到了啊,所以说,你看的每一篇blog可能都是我写了2次以上的--.哎!! 代码改变世界,继续......... Python基础 ...
- 利用xcopy命令实现本地文件复制到远程服务器的方法
net use \\192.168.1.198\ipc$ Zqf198703 /user:royalpeak xcopy g:\backup\*.* \\192.168.1.198\数据备份 /D / ...
- shell编程之sed
一.sed (Stream Editor) 1.定位行:sed -n '12,~3p' pass #从第12行开始,直到下一个3的倍数行(12-15行)sed -n '12,+4p' pass #从第 ...
- JavaScript Function arguments.callee caller length return
一.Function 函数是对象,函数名是指针. 函数名实际上是一个指向函数对象的指针. 使用不带圆括号的函数名是访问函数指针,并非调用函数. 函数的名字仅仅是一个包含指针的变量而已.即使在不同的环境 ...
- Java Queue 各种方法的区别
再Java里的某些集合类,其实是实现了多个接口的,所以就会同时又多种方法针对同一种操作,比如LinkedList类. 首先看一下java集合类的继承关系图: 这里简单对其重复的方法做点简单的区分. o ...