Maven--要点笔记

来源:互联网 发布:vb中case是什么意思 编辑:程序博客网 时间:2024/05/16 19:42
--maven笔记


1.maven命令


2.archetype插件:用于创建符合maven规定的目录骨架  
命令: mvn archetype:generate


3.
坐标:构件
仓库: 本地仓库和远程仓库
镜像仓库 :http://maven.net.cn/content/groups/public
更改本地仓库位置


4.maven生命周期:
clean 清理项目
pre-clean 执行清理前的工作
clean 清理上一次构建生成的文件
post-clean 执行清理后的文件


default 构建项目(核心)
compile test package install


site 生成项目站点
pre-site 在生成项目站点前要完成的工作
site 生成项目的站点文件
post-site 在生成项目站点后要完成的工作
site-deploy 发布生成的站点到服务器上


5.maven提供的一些插件


6.pox.xml解析:
设置依赖是否可选
<optional>

排除依赖传递列表
<exclusions> <exclusion>


依赖管理
<dependencies> <dependency>


插件
<build> <plugins> <plugin>

子模块继承父模块
<parent>

模块
<modules> <module>

依赖范围:  --参数(compile(默认)\provided(编译、测试有效)\runtime(测试、运行)\test(测试)\system(编译、测试、可移植差)\import(导入的范围,只使用在dependencyManagement中,表示从其他的pom中导入dependency配置))
<scope> 


依赖传递 :



依赖冲突:
原则:
短路优先,
先声明先优先(路径长度一样)

7.聚合和继承
聚合(modules module标签)
继承 
举个例子:
--父类pom:
<properties>
<junit.version>4.0.0</junit.version>
</properties>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependencies>


</dependencyManagement>


--子类pom:
<parent>
父pom坐标
</parent>


8.maven使用Jetty 和 tomcat服务运行web项目









0 0
原创粉丝点击