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

  1. IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)

    Eclipse用多了,IntelliJ中创建Maven聚合项目可能有小伙伴还不太熟悉,我们今天就来看看. IntelliJ中创建普通的Java聚合项目相对来说比较容易,不会涉及到web操作,涉及到we ...

  2. 38.IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)

    转自:https://blog.csdn.net/u012702547/article/details/77431765 Eclipse用多了,IntelliJ中创建Maven聚合项目可能有小伙伴还不 ...

  3. maven命令创建web骨架项目

    maven命令创建web骨架项目有以下两种方式: mvn archetype:create -DgroupId=org.seckill -DartifactId=seckill -Darchetype ...

  4. IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)(转载)

    创建parent项目 1.打开IDEA,注意这里不要勾选模板,用模板创建过maven项目的小伙伴都知道模板创建项目非常慢,所以这里不要选模板,需要的文件夹我们后面自己来创建就可以了.所以这个页面直接点 ...

  5. maven系列之二maven项目的创建和maven项目的结构

    maven系列之一简单介绍了maven的基本信息,安装和配置,大家对maven有一个大概的了解,但是在maven项目开发中远远不够,为了进一步了解maven,现在我们介绍maven项目的创建和mave ...

  6. eclipse中创建一个maven项目

    1.什么是Maven Apache Maven 是一个项目管理和整合工具.基于工程对象模型(POM)的概念,通过一个中央信息管理模块,Maven 能够管理项目的构建.报告和文档. Maven工程结构和 ...

  7. 使用Intellij Idea创建简单Maven项目(转)

    我是学Java Web的,基本靠自学,在网上收集了各种视频资料,逐一的看,代码逐一的敲.学习了这么久之前一直未成想过要把自己的学习路程记录下来,在网上也看到过很多人把自己的学习历程以及遇到的问题写在了 ...

  8. eclipse 创建聚合maven项目

    本人不想花太多时间去排版,所以这里排版假设不好看,请多多包涵! 一直都在用maven,可是却基本没有自己创建过maven项目,今天也试着创建一个. 1.打开eclipse.然后new,other,然后 ...

  9. Maven(一)如何用Eclipse创建一个Maven项目

    1.什么是Maven Apache Maven 是一个项目管理和整合工具.基于工程对象模型(POM)的概念,通过一个中央信息管理模块,Maven 能够管理项目的构建.报告和文档. Maven工程结构和 ...

随机推荐

  1. 在ASP.NET Web Forms中使用页面导出伪xls Excel表格

    将数据导出为Excel表格是比较常见的需求,也有很多组件支持导出真正的Excel表格.由于Excel能打开HTML文件,并支持其中的table元素以及p之类的文本元素的显示,所以把.html扩展名改为 ...

  2. gRPC编码初探(java)

    背景:gRPC是一个高性能.通用的开源RPC框架,其由Google主要面向移动应用开发并基于HTTP/2协议标准而设计,基于ProtoBuf(Protocol Buffers)序列化协议开发,且支持众 ...

  3. z-index研究

    文章来源: http://www.neoease.com/css-z-index-property-and-layering-tree/ 总结: 1.z-index只有在设置position:rela ...

  4. JObject对json的操作

    一,需去程序集添加using Newtonsoft.Json.Linq;引用 using System; using System.Collections.Generic; using System. ...

  5. bootstrap复习:组件

    一.下拉菜单 1.实例:将下拉菜单触发器和下拉菜单都包裹在 .dropdown 里,或者另一个声明了 position: relative; 的元素.然后加入组成菜单的 HTML 代码.为下拉菜单的父 ...

  6. mybatis 批量插入值的sql

    <insert id="insertAwardPic" useGeneratedKeys="true" parameterType="java. ...

  7. CentOS6.4安装go环境

    在官网上下载go1.6.linux-amd64.tar.gz 解压缩并拷贝程序到相应路径下 #tar -zxvf go1.6.linux-amd64.tar.gz #cp -rf go /usr/lo ...

  8. inno setup 安装个界面提示信息修改

    对于inno setup打包的安装文件,各界面中的提示信息可以在安装编译脚本 xxx.iss 中的 [Messages] 段设置,如果不知道要设置的信息的变量名,可以到 inno setup的安装目录 ...

  9. opencv使用convexityDefects计算轮廓凸缺陷

    引自:http://www.xuebuyuan.com/1684976.html http://blog.csdn.net/lichengyu/article/details/38392473 htt ...

  10. 清空form

    在清空form是遇到问题 document.formname.reset(); 当reset对checkbox不起作用时,清空其需要用 $(" ").attr("chec ...