Maven 初学(一)基本概念
Pom中有三个主要元素
Groupid,artifactid,version
goupid 是一个组织唯一的标识 例如 com.ibm.www
artifactid 是一个工程呢ID ibm-project
version 代表一个版本 例如 com.ibm.www.ibm-project.1.0
maven执行一个目标(goal)有以下几个步骤
prepare-resources 资源的拷贝
compile 源代码拷贝阶段
package 创建jar/war包阶段
install 安装包到本地或者远程库中
mvn clean dependency:copy-dependencies package
clean 首先被执行,
然后dependency:copy-dependencies被执行
然后是package被执行
clean 的 Lifecycle
pre-clean
clean
post-clean
默认 build Lifecycle
validate 验证工程是否正确,所有必要的信息是否有效
| Lifecycle Phase | Description |
|---|---|
| validate | Validates whether project is correct and all necessary information is available to complete the build process. |
| initialize | Initializes build state, for example set properties |
| generate-sources | Generate any source code to be included in compilation phase. |
| process-sources | Process the source code, for example, filter any value. |
| generate-resources | Generate resources to be included in the package. |
| process-resources | Copy and process the resources into the destination directory, ready for packaging phase. |
| compile | Compile the source code of the project. |
| process-classes | Post-process the generated files from compilation, for example to do bytecode enhancement/optimization on Java classes. |
| generate-test-sources | Generate any test source code to be included in compilation phase. |
| process-test-sources | Process the test source code, for example, filter any values. |
| test-compile | Compile the test source code into the test destination directory. |
| process-test-classes | Process the generated files from test code file compilation. |
| test | Run tests using a suitable unit testing framework(Junit is one). |
| prepare-package | Perform any operations necessary to prepare a package before the actual packaging. |
| package | Take the compiled code and package it in its distributable format, such as a JAR, WAR, or EAR file. |
| pre-integration-test | Perform actions required before integration tests are executed. For example, setting up the required environment. |
| integration-test | Process and deploy the package if necessary into an environment where integration tests can be run. |
| post-integration-test | Perform actions required after integration tests have been executed. For example, cleaning up the environment. |
| verify | Run any check-ups to verify the package is valid and meets quality criterias. |
| install | Install the package into the local repository, which can be used as a dependency in other projects locally. |
| deploy | Copies the final package to the remote repository for sharing with other developers and projects. |
local Repository 本地库
可以在settings文件中设置本地库位置
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:/MyLocalRepository</localRepository>
</settings>
Central Repository 中心库
maven在本地库中不能找到依赖的时候,就回去中心库中寻找
http://repo1.maven.org/maven2/
Remote Repository远程库
<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>com.companyname.projectgroup</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.companyname.common-lib</groupId>
<artifactId>common-lib</artifactId>
<version>1.0.0</version>
</dependency>
<dependencies>
<repositories>
<repository>
<id>companyname.lib1</id>
<url>http://download.companyname.org/maven2/lib1</url>
</repository>
<repository>
<id>companyname.lib2</id>
<url>http://download.companyname.org/maven2/lib2</url>
</repository>
</repositories>
</project>
使用archetype插件创建工程
C:\MVN>mvn archetype:generate
-DgroupId=com.companyname.bank
-DartifactId=consumerBanking
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
参考自:http://www.tutorialspoint.com/maven/maven_quick_guide.htm
Maven 初学(一)基本概念的更多相关文章
- 【Java EE 学习 82 下】【MAVEN整合Eclipse】【MAVEN的一些高级概念】
一.MAVEN整合Eclipse MAVEN是非常优秀,但是总是要开命令行敲命令是比较不爽的,我们已经习惯了使用IDE,所以还有一种将MAVEN整合到Eclipse的方法. 详情查看:http://w ...
- maven使用.02.一些概念
在上一篇POST中,简要的介绍了一下maven的特点,优势,安装.并建立了一个简单地Hello world工程.这一篇POST中,将主要会介绍一下Maven的一些约定. pom.xml文件 Maven ...
- maven第二天——重要概念与其它操作
一.在eclipse中建立工程 在day01中我们搭建了eclipse的maven环境,接下来我们开始建立maven项目 1.在eclipse中建立JAVA工程 file->new->ma ...
- maven用途、核心概念、用法、常用参数和命令、扩展
设置问题解决. http://trinea.iteye.com/blog/1290898 本文由浅入深,主要介绍maven的用途.核心概念(Pom.Repositories.Artifact.Buil ...
- Ant,Maven与Gradle的概念的理解
转载地址:http://www.jianshu.com/p/cd8fe9b16369# 我们还是以AndroidStudio 2.1.1为例来讲. 用AndroidStudio就逃不开跟Gradle打 ...
- Maven 初学+http://mvnrepository.com/
了解 maven是一款服务于java平台的自动化构建工具(项目管理工具) 构建:全方位.多角度.深层次地建立 项目构建是一个项目从:源代码.编译.测试.打包.部署.运行的过程 用来解决团队开发遇到的问 ...
- Maven 生命周期的概念(指令默认顺序执行)
生命周期的概念 IDEA中使用maven构建项目都集中放到了窗口右侧"Maven Projects"中,点击该区域可以直观的看到,maven中几个常用指令都归类为LifeCycle ...
- Maven笔记之核心概念及常用命令
Maven的核心概念 Maven是一款服务于java平台的自动化构建工具. 自动化构建工具还有:make->ant->maven->gradle 1.约定的目录 2.P ...
- maven初学(二)archeType插件使用
archeType是一个maven插件,它的主要功能是根据模板来创建工程结构 创建工程结构: 1,创建工程目录 2,输入命令:mvn archetype:generate 3,选择需要的archety ...
随机推荐
- gnuplot 学习笔记
1 如何运行 gnuplot是一个命令行输入的工具,把命令行写入一个文本file1 file2.使用下列方式运行. gnuplot {option} file1 file2 2 产生一个图标,不管数据 ...
- matlab生成HEX文件-任意信号 大于64K长度
HEX文件格式不赘述,写里直接放上代码.请批评改正. %%convert a signal data into hex file format % data format:16bit % signal ...
- NOIP2008普及组传球游戏(动态规划)——yhx
题目描述 上体育课的时候,小蛮的老师经常带着同学们一起做游戏.这次,老师带着同学们一起做传球游戏. 游戏规则是这样的:n个同学站成一个圆圈,其中的一个同学手里拿着一个球,当老师吹哨子时开始传球,每个同 ...
- opencv 3.0 DPM Cascade 检测 (附带TBB和openMP加速)
opencv 3.0 DPM cascade contrib模块 转载请注明出处,楼燚(yì)航的blog,http://www.cnblogs.com/louyihang-loves-baiyan/ ...
- 怎样快速免费获取Windows版本的ZBrush
ZBrush是一款专业的3D绘制软件及数字雕刻软件,随着3D技术的不断进步,ZBrush也是越来越受到业内欢迎,在世界拥有了众多的粉丝和爱好者.相信很多用户对软件的体验就是从使用的版本开始的,本文就教 ...
- WPF数字输入框和IP地址输入框
数字输入框 简介 在业务中,我们经常需要限制用户的输入,比如限制输入长度,限制只能输入数字等等.限制输入长度WPF内置的TextBox已经帮我们解决了,但是限制输入数字却并未在WPF中内置解决方案.使 ...
- 反序列化存入数据库里面的session数据
session数据存取的方法可通过session.serialize_handler方法来判断,反序列化可通过下面的unserialize方法,参考http://stackoverflow.com/q ...
- Android SQLite (二) 基本用法
在Android开发中SQLite起着很重要的作用,网上SQLite的教程有很多很多,不过那些教程大多数都讲得不是很全面.本人总结了一些SQLite的常用的方法,借着论坛的大赛,跟大家分享分享的. 一 ...
- java的IO操作之--RandomAccessFile
目标: 1)掌握RandomAccessFile类的作用. 2)用RandomAccessFile读取指定位置的数据. 具体内容 RandomAccessFile类的主要功能是完成随机读取功能,可以读 ...
- 11Spring_AOP编程(AspectJ)_概述
AspectJ 是一个框架 (第三方AOP框架 ),提供切面编程 ,编写一个Aspect 支持多个Advice和多个PointCut .对比前一种提到的传统的Aop编程,AspctJ更加的常用.Asp ...