当前位置: 首页 > news >正文

网站开发前后端工具组合网站备案主体负责人

网站开发前后端工具组合,网站备案主体负责人,女装网站建设规划,长沙广告网页设计最新招聘信息转载自 Maven的pom.xml文件详解------The Basics Maven坐标 GroupId、artifactId和version构成了Maven的坐标#xff08;groupId和version可以从parent继承#xff09;#xff0c;指定了组件在Maven仓库中的位置。Maven中的每个组件都有一个坐标#xff0c;通过这个坐标…转载自  Maven的pom.xml文件详解------The Basics Maven坐标 GroupId、artifactId和version构成了Maven的坐标groupId和version可以从parent继承指定了组件在Maven仓库中的位置。Maven中的每个组件都有一个坐标通过这个坐标我们在自己的项目中可以设置对该组件的依赖。  ------groupId项目属于哪个组往往和项目所在的组织或公司存在关联  ------artifactId当前Maven项目在组中唯一的ID  ------version定义当前项目的版本如1.0-SNAPSHOTSNAPSHOT表示快照说明该项目还处于开发阶段是不稳定版本  ------packaging当我们有了groupId:artifactId:version作为地址后还需要packaging为我们提供组件的类型例如packagingwar/packaging标识组件为一个war。如果packaging不指定默认值为jar当前可选值为pom, jar, maven-plugin, ejb, war, ear, rar, par  ------classifier可选坐标也可以展示为groupId:artifactId:packaging:classifier:version。 POM关联 Maven的一个有力的地方就在于对项目关联的处理包括依赖、继承和聚合多模块项目。 Dependencies dependenciesdependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.0/versiontypejar/typescopetest/scopeoptionaltrue/optional/dependency... /dependencies ------groupId、artifactId、version依赖组件的坐标如果当Maven通过这些坐标无法从中心仓库获取该组件时可以通过下面的方法处理   1、用安装插件安装本地依赖在命令行中输入   mvn install:install-file -Dfilenon-maven-proj.jar -DgroupIdsome.group -DartifactIdnon-maven-proj -Dversion1 -Dpackagingjar   2、创建你自己的仓库并部署它   3、设置依赖scope到system并定义一个systemPath但这个不推荐。 ------type对应所以来的组件的packaging ------scop用于控制依赖的范围有以下几种范围供选择   1、compile编译依赖范围默认对于所有的classpath都是有效的   2、provided仅对编译和测试classpath有效   3、runtime编译时不需要尽在运行时需要   4、test仅用于测试   5、system和provided类似只是你需要提供JAR组件不再在仓库中查找。 ------systemPath当scop配置为system时就需要它了 dependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.0/versiontypejar/typescopesystem/scopesystemPath$(object.path)/lib/junit.jar/systemPathoptionaltrue/optional/dependency ------optional设置为true标识该依赖只对该项目有效如果其他项目依赖该项目该依赖将不会传递。 Exclusions 该配置告诉Maven你不想包含的该依赖的依赖即依赖传递的依赖。 dependenciesdependencygroupIdorg.apache.maven/groupIdartifactIdmaven-embedder/artifactIdversion2.0/versionexclusionsexclusiongroupIdorg.apache.maven/groupIdartifactIdmaven-core/artifactId/exclusion/exclusions/dependency... /dependencies 也可以使用通配符表示排除所有传递的依赖。 dependenciesdependencygroupIdorg.apache.maven/groupIdartifactIdmaven-embedder/artifactIdversion2.0/versionexclusionsexclusiongroupId*/groupIdartifactId*/artifactId/exclusion/exclusions/dependency... /dependencies Inheritance 继承是一个有力的工具在maven中使用继承时需要为parent和aggregation多模块项目设置packaging为pompackagingpom/packaging然后就子项目就可以继承该POM了。 parentgroupIdorg.codehaus.mojo/groupIdartifactIdmy-parent/artifactIdversion2.0/versionrelativePath../my-parent/relativePath /parent relativePath是可选的指定parent的搜索路径如果配置了Maven将首先搜索relativePath然后本地仓库最后远程仓库查找parentPOM。 POM就像Java对象最终都继承自java.lang.Object一样所有的POM都继承自一个Super POM你通过查ungjianyige最小化的pom.xml并在命令行中执行 mvn help:effective-pom来查看Super POM对你的POM的影响下面是Maven 3.0.4的Super POM该Super POM的位置在apache-maven-version\lib\maven-model-builder-version.jar\org\apache\maven\model\下面文件名pom-4.0.0.xml。 projectmodelVersion4.0.0/modelVersionrepositoriesrepositoryidcentral/idnameCentral Repository/nameurlhttp://repo.maven.apache.org/maven2/urllayoutdefault/layoutsnapshotsenabledfalse/enabled/snapshots/repository/repositoriespluginRepositoriespluginRepositoryidcentral/idnameCentral Repository/nameurlhttp://repo.maven.apache.org/maven2/urllayoutdefault/layoutsnapshotsenabledfalse/enabled/snapshotsreleasesupdatePolicynever/updatePolicy/releases/pluginRepository/pluginRepositoriesbuilddirectory${project.basedir}/target/directoryoutputDirectory${project.build.directory}/classes/outputDirectoryfinalName${project.artifactId}-${project.version}/finalNametestOutputDirectory${project.build.directory}/test-classes/testOutputDirectorysourceDirectory${project.basedir}/src/main/java/sourceDirectoryscriptSourceDirectorysrc/main/scripts/scriptSourceDirectorytestSourceDirectory${project.basedir}/src/test/java/testSourceDirectoryresourcesresourcedirectory${project.basedir}/src/main/resources/directory/resource/resourcestestResourcestestResourcedirectory${project.basedir}/src/test/resources/directory/testResource/testResourcespluginManagement!-- NOTE: These plugins will be removed from future versions of the super POM --!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) --pluginspluginartifactIdmaven-antrun-plugin/artifactIdversion1.3/version/pluginpluginartifactIdmaven-assembly-plugin/artifactIdversion2.2-beta-5/version/pluginpluginartifactIdmaven-dependency-plugin/artifactIdversion2.1/version/pluginpluginartifactIdmaven-release-plugin/artifactIdversion2.0/version/plugin/plugins/pluginManagement/buildreportingoutputDirectory${project.build.directory}/site/outputDirectory/reportingprofiles!-- NOTE: The release profile will be removed from future versions of the super POM --profileidrelease-profile/idactivationpropertynameperformRelease/namevaluetrue/value/property/activationbuildpluginsplugininheritedtrue/inheritedartifactIdmaven-source-plugin/artifactIdexecutionsexecutionidattach-sources/idgoalsgoaljar/goal/goals/execution/executions/pluginplugininheritedtrue/inheritedartifactIdmaven-javadoc-plugin/artifactIdexecutionsexecutionidattach-javadocs/idgoalsgoaljar/goal/goals/execution/executions/pluginplugininheritedtrue/inheritedartifactIdmaven-deploy-plugin/artifactIdconfigurationupdateReleaseInfotrue/updateReleaseInfo/configuration/plugin/plugins/build/profile/profiles/project Dependency Management dependencyManagement用于在parent项目定义一个依赖如 dependencyManagementdependencies dependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.0/versiontypejar/typescopecompile/scopeoptionaltrue/optional/dependency/dependencies /dependencyManagement 然后从这个parent继承的POMs就能设置他们的依赖为 dependencies dependency groupIdjunit/groupIdartifactIdjunit/artifactId/dependency /dependencies 继承的POM的dependency的其它信息可以从parent的dependencyManagement中获得这样的好处在于可以将依赖的细节放在一个控制中心子项目就不用在关心依赖的细节只需要设置依赖。 Aggregation或者Multi-Module 在多模块的项目中可以将一个模块的集合配置到modules中。modulesmodulemy-project/modulemoduleanother-project/module /modules 在这里列出的模块不需要考虑顺序Maven将自己根据依赖关系排序。 Properties Maven中的Properties就像Ant中的可以在POM的任何地方通过${X}来返回属性的值X就表Poperty。 存在以下5种不同的类型 1、env.X将返回环境变量的值如${env.PATH}返回PATH环境变量的值 2、project.XPOM中的对应元素的值.表示在POM中的路径如projectversion1.0/version/project可以通过${project.version}获取值 3、settings.Xsettings.xml中包含的对应元素的值.表示路径如 settingsofflinefalse/offline/settings可以通过${settings.offline}获取 4、Java System Properties所有可以通过java.lang.System.getProperties()获取到的属性在POM属性中都是可用的如${java.home} 5、X在POM的properties /中设置的元素如 propertiessomeVarvalue/someVar/properies通过${someVar}获取。
http://wiki.neutronadmin.com/news/1065/

相关文章: