Maven初体验

来源:互联网 发布:php按值删除数组元素 编辑:程序博客网 时间:2024/06/07 02:11
<groupId></groupId>项目的包名
<artifactId></artifactId>模块名
<version></version>

<dependencies>
<dependency>
<groupId>
<artifactId>
<version>
<dependency>
<dependencies>


完整的项目构建过程

清理,编译,测试,打包,集成测试,验证,部署

clean 清理项目  : pre-clean,   clean,  post-clean

default构建项目 : compile, test, package, install

site生成项目站点 : pre-site, post-site, destory-site

clean compile test package install

install : 是将你打好的jar安装到本地库中,一般没有设置是在用户目录下的,m2/


maven 有很多插件,可以引入插件用来执行一些maven命令

http://maven.apache.org/plugins/index.html

引入插件语法: pom.xml
maven中可以选择依赖的命令

<build>
<plugins>
<groupId>org.apache.maven.plugins</guoupId>引入插件的地址
<artifactId>maven-source-plugin</artifactId>名称
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
//打源代码的jar 包

版本的演变 :
snapshot快照
alpha内部测试
beta公测
Release稳定
GA正式发布


<name></name>项目描述名,一般用于文档
<url></url>项目地址
<description></description>
<dependencyManagement>依赖管理
<parent></parent>通常用于在子模块中对父模块的POM的继承
<modules>可以指定对多个模块进行编译
<module>
<module>
</modules>

<scope></scope>依赖的范围
编译、测试、运行

compile : 3
provided :测试,编译
runtime:测试,运行
test:测试
system:与本机系统相关联,可移植性差
import:导入的范围
适用于<dependencyManageManagement>
表示从其它地方导入的依赖

依赖传递
clean - package -install

用 install将工程打成JAR到本地仓库

依赖冲突
  1. 短路优先
  2. 先依赖先优先原则


聚合
不用一个一个install
可用<modules>标签,对所有的maven工程进行统一install


和传递
<dependencyManagement>

可添加Jetty插件

jetty:run运行jetty服务
0 0
原创粉丝点击