您好,欢迎访问三七文档
Maven新手笔记2009.12从两条maven命令说起1.mvnarchetype:create-DgroupId=com.alipay.mvndemo-DartifactId=demo-DpackageName=com.alipay.mvndemomvn-maven2命令archetype:create-mavengoalartifactId-唯一名称groupId-唯一标识符packageName-包名-Dname=value-systemproperty2.mvnpackgeSystem.getProperties().setProperty(name,value);runphasegotoExplorerMaven是什么一个构建工具一套项目管理框架Maven是一个项目管理工具,它包含了一个项目对象模型、一组标准集合、一个项目生命周期、一个依赖管理系统和用来运行定义在生命周期阶段中插件目标的逻辑。PluginsandGoalsmvnarchetype:create…archetype-plugin,archetype:create-goalarchetype:createarchetype:generatearchetype:create-from-projectarchetype:crawlPOMProjectObjectModel坐标(Coordinates)Maven用于定位组件的一组标识符classifiertestng-5.10-jdk14.jartestng-5.10-jdk14.jar.md5testng-5.10-jdk14.jar.sha1testng-5.10-jdk15.jartestng-5.10-jdk15.jar.md5testng-5.10-jdk15.jar.sha1依赖管理(DependencyManagement)type==packagingpackagingjar/packagingtypejar/typeclassifier、systemPath、optional生命周期(Lifecycle)mvnpackagegotoExplorervalidateinitializegenerate-sourcesprocess-sourcesgenerate-resourcesprocess-resourcescompileprocess-classesgenerate-test-sourcesprocess-test-sourcesgenerate-test-resourcesprocess-test-resourcestest-compileprocess-test-classestestprepare-packagepackagepre-integration-testintegration-testpost-integration-testverifyinstalldeployDefaultLifecycle常见命令的生命周期gotoExplorergotoCmdmvneclipse:cleanmvnclean-oinstall-Dmaven.test.skip=truemvneclipse:eclipse-Dmaven.test.skip=truemvneclipse:eclipsemvntestmvncleanpre-cleanclean-clean:cleanpost-cleanvalidate…testmvninstallvalidate…installmvn–ocleaninstall-Dmaven.test.skip=truemvneclipse:eclipse-DdownloadSources=true-DdownloadJavadocs=true常见命令的生命周期mvneclipse:eclipsemvneclipse:clean…[INFO]Sourcesforsomeartifactsarenotavailable.Pleaserunthesamegoalwiththe-DdownloadSources=trueparameterinordertocheckremoterepositoriesforsources.Listofartifactswithoutasourcearchive:ocom.alipay.common:alipay-common-lang:2.0.1.20090522…Javadocforsomeartifactsisnotavailable.Pleaserunthesamegoalwiththe-DdownloadJavadocs=trueparameterinordertocheckremoterepositoriesforjavadoc.Listofartifactswithoutajavadocarchive:ocom.alibaba.toolkit.common:toolkit-common-lang:1.0…____________________________________________________________________________________________________________________________________________mvncleaneclipse:clean仓库(Repositories)本地仓库:C:\DocumentsandSettings\USERNAME\.m2\repository远程仓库:C:\DocumentsandSettings\USERNAME\.m2\setting.xml或%MAVEN_HOME%\conf\setting.xml或pom.xml多模块项目多模块项目多模块项目多模块项目多模块项目1.创建父pom.xml:maven坐标、模块信息。2.创建各子pom.xml:父坐标、坐标、依赖等3.依赖优化:依赖管理器、依赖排除、依赖范围、依赖版本界限。4.插件管理5.配置仓库依赖范围compile(编译范围)默认范围,编译范围依赖在所有的classpath中可用,同时它们也会被打包。provided(已提供范围)只有在当JDK或者一个容器已提供该依赖之后才使用。在编译classpath(不是运行时)可用。它们不是传递性的,也不会被打包。runtime(运行时范围)在运行和测试的时候需要,但在编译的时候不需要。test(测试范围)test范围依赖在一般的编译和运行时都不需要,它们只有在测试编译和测试运行阶段可用system(系统范围)与provided类似,但是你必须显式的提供一个对于本地系统中JAR文件的路径。资源Maven:ADeveloper'sNotebookMavenDefinitiveGuideQ&A
本文标题:Maven新手笔记
链接地址:https://www.777doc.com/doc-3326213 .html