mvn学习整理(配置+命令+Setting.xml+Pom.xml)_第1页
mvn学习整理(配置+命令+Setting.xml+Pom.xml)_第2页
mvn学习整理(配置+命令+Setting.xml+Pom.xml)_第3页
mvn学习整理(配置+命令+Setting.xml+Pom.xml)_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Maven 环境变量配置:变量名: M2_HOME 变量值: D:binapache-maven-2.2.1(安装路径 )在 path 值后面追加 %M2_HOME%bin;( 注意要加分号 )测试:Mvn -/ersionmaven 常用命令为 :mvn archetype:create :创建 Maven 项目mvn compile :编译源代码mvn test-compile :编译测试代码mvn test : 运行应用程序中的单元测试 mvn site : 生成项目相关信息的网站 mvn clean :清除目标目录中的生成结果 mvn package : 依据项目生成 jar 文件 m

2、vn install :在本地 Repository 中安装 jar mvn eclipse:eclipse :生成 Eclipse 项目文件 生成项目建一个 JAVA 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=App 建一个 web 项目 : mvn archetype:create -DgroupId=com.demo -DartifactId=web-app -DarchetypeArtifactId=maven-archetype-webapparchetype 是一个内建插件,他的 create 任务将建立项目

3、骨架 archetypeArtifactId 项目骨架的类型, DartifactId 项目名称 可用项目骨架有:maven-archetype-archetype maven-archetype-j2ee-simple maven-archetype-mojo maven-archetype-portlet maven-archetype-profiles maven-archetype-quickstart maven-archetype-simple maven-archetype-site maven-archetype-site-simple, and maven-archetype

4、-webappSetting.xml 配置文件 localRepository :本地库存位置, jar 包保存位置,默认 $user.dir/.m2/repository offline: true/false,如不想每次编译都去查找远程中心库,就设置为true,前提是已下载好包Servers:配置特定的用户<servers><server> <id/><username/><password/><privatekey/><pssphrase/> <filePermissions/><dir

5、ectoryPermissions/><configuration/></server></servers>id :用于匹配 distributionManagement 库 idusername,password:用于登陆此服务器的用户名和密码 privateKey , passphrase:设置 private Key,及 passphrase filePermissions,directoryPermissions :访问权限 664/775mirrosrs :镜像库,用于添加其他库<mirrors><miror><

6、id/><name/><url/><mirroOf/></mirror></mirrors>id, name :唯一的标志,用来区别镜像url:镜像的urlmirrorOf :此镜像指向的服务 idProxies :代理设置,用于无法直接访问中心库的配置<proxies><proxy><id/><active/><protocol/><host/><port/><username/><password/><nonPr

7、oxyHosts/> </proxy></proxies>id :代理的标志 active :是否激活代理protocol , host, port: protocol : /host: port 代理 user name, password :用户名密码 non ProxyHosts :不需要代理的 host repositories 禾口 plug in Reposit on ries 定义本地开发库 用于 release 发布<repositories><repository><id/><name/><u

8、rl/><releases> <enabled/><updatePolicy/><checksumPolicy/></releases><snapshots><enabled/></snapshots><layout/></repository></repositories>Pom.xml 配置文件在 pom.xml 中定义 jar 包版本还有依赖,管理 jar 文件。包括配置文件;开发需要遵循的规则,缺陷管理系统,组织和lice nses,项目的依赖性gr

9、oupId :项目或组织唯一标志,并生成项目路径artifactId :项目名称 version :项目版本packaging :打包的机制,如 jar, pom, warmaven 中继承的定义 <project><modelVersion/><groupId/><version/><packaging/> </project>父项目 packaging 类型需要为 pom ,用于 parent 和合成多个项目,子项目为 <parent><groupId/><artifctId/>&l

10、t;version/></parent>Modules 合成<modules><module>tc-dient</moduble><module>tc-server</module></modules>build 设置:用于编译设置,包括两个主要元素, build,report <project><project><build/><profies><profile><build/></profile></profie

11、s></profiles></project>build-plugin 插件 <project><build><plugins><plugin><groupId/><artifactId/><version/> <extensions/><executions/></plugin></plugins></build></project>extensions: true/false 是否装载插件扩展,默认为 fa

12、lseinherited : true/false此插件配置是否应用于poms(继承)configuration :指定插件配置 depe nden cies :插件需要依赖的包executions:用于配置execution目标,一个插件可以有多个目标 build-resources 资源,项目中需要指定的资源如:perties<project><build><resources> <resource><targetPath/><filtering/><directory/><incl

13、udes><include/></includes><excludes><exclude/></excludes></resource></resources><testResources></testResources></build></project>resources:列表,包括所有的资源targetPath:指定目标路径,用于放置资源,用于buildfiltering :是否替换资源中属性 placeholddirectory :资源所在的位置in

14、 eludes :样式,包括资源excludes :排除的资源 testResources测试资源列表depe nden cies :依赖关系<dependencies> <dependency><groupId/><artifactId/><version/> <type/><scope/><optional/> </dependency></dependencies> groupId,artifactId,version :描述了依赖的项目唯一标志 使用以下的命令安装:mvnin stall:i nstall-file-Dfile=non-mave n-proj.jar-Dgroupld=some.group-DartifactId=non-mave n-proj-Dversion=1创建自己的库,并配置,使用deploy:deploy-file设置此依赖范围为system,定义一个系统路径。不提倡。type :相应的依赖产品包形式,如jar, w

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论