maven中maven pom.xml build配置文件怎么看

1188人阅读
Maven 2 的 pom.xml 配置说明。
pom.xml文件(实践用):
&project xmlns=&http://maven.apache.org/POM/4.0.0&
&&& xmlns:xsi=&http://www.w3.org/2001/XMLSchema-instance&
&&& xsi:schemaLocation=&http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&&
&&& &modelVersion&4.0.0&/modelVersion&
&&& &!-- groupId: groupId:项目或者组织的唯一标志,并且配置时生成的路径也是由此生成,
&&& &&& 如com.mycompany.app生成的相对路径为:/com/mycompany/app --&
&&& &groupId&asia.banseon&/groupId&
&&& &!-- artifactId: 项目的通用名称 --&
&&& &artifactId&banseon-maven2&/artifactId&
&&& &!-- packaging: 打包的机制,如pom, jar, maven-plugin, ejb, war, ear, rar, par&& --&
&&& &packaging&jar&/packaging&
&&& &!-- version:项目的版本 --&
&&& &version&1.0-SNAPSHOT&/version&
&&& &!-- 项目的名称, Maven 产生的文档用 --&
&&& &name&banseon-maven&/name&
&&& &!-- 哪个网站可以找到这个项目,提示如果 Maven 资源列表没有,可以直接上该网站寻找, Maven 产生的文档用 --&
&&& &url&/banseon&/url&
&&& &!-- 项目的描述, Maven 产生的文档用 --&
&&& &description&A maven project to study maven.&/description&
&&& &!-- 开发者信息 --&
&&& &developers&
&&& &&& &developer&
&&& &&& &&& &id&HELLO WORLD&/id&
&&& &&& &&& &name&banseon&/name&
&&& &&& &&& &email&&/email&
&&& &&& &&& &roles&
&&& &&& &&& &&& &role&Project Manager&/role&
&&& &&& &&& &&& &role&Architect&/role&
&&& &&& &&& &/roles&
&&& &&& &&& &organization&demo&/organization&
&&& &&& &&& &organizationUrl&/banseon&/organizationUrl&
&&& &&& &&& &properties&
&&& &&& &&& &&& &dept&No&/dept&
&&& &&& &&& &/properties&
&&& &&& &&& &timezone&-5&/timezone&
&&& &&& &/developer&
&&& &/developers&
&&& &!-- 类似 developers --&
&&& &contributors&&/contributors&
&&& &!-- 本项目相关 mail list, 用于订阅等信息 --&
&&& &mailingLists&
&&& &&& &mailingList&
&&& &&& &&& &name&Demo&/name&
&&& &&& &&& &!-- Link mail --&
&&& &&& &&& &post&&/post&
&&& &&& &&& &!-- mail for subscribe the project --&
&&& &&& &&& &subscribe&&/subscribe&
&&& &&& &&& &!-- mail for unsubscribe the project --&
&&& &&& &&& &unsubscribe&&/unsubscribe&
&&& &&& &&& &archive&
&&& &&& &&& http://banseon/demo/dev/
&&& &&& &&& &/archive&
&&& &&& &/mailingList&
&&& &/mailingLists&
&&& &!-- 项目的问题管理系统(Bugzilla, Jira, Scarab,或任何你喜欢的问题管理系统)的名称和URL,本例为 jira --&
&&& &issueManagement&
&&& &&& &system&jira&/system&
&&& &&& &url&/banseon&/url&
&&& &/issueManagement&
&&& &!-- organization information --&
&&& &organization&
&&& &&& &name&demo&/name&
&&& &&& &url&/banseon&/url&
&&& &/organization&
&&& &!-- License --&
&&& &licenses&
&&& &&& &license&
&&& &&& &&& &name&Apache 2&/name&
&&& &&& &&& &url&/banseon/LICENSE-2.0.txt&/url&
&&& &&& &&& &distribution&repo&/distribution&
&&& &&& &&& &comments&A business-friendly OSS license&/comments&
&&& &&& &/license&
&&& &/licenses&
&&& &&& - scm(software configuration management)标签允许你配置你的代码库,为Maven web站点和其它插件使用。
&&& &&& - 如果你正在使用CVS或Subversion,source repository页面同样能给如何使用代码库的详细的、工具相关的指令。
&&& &&& - 下面是一个典型SCM的配置例子
&&& &&& &!-- 项目在 svn 上对应的资源 --&
&&& &&& &connection&
&&& &&& &&& scm:svn:/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk)
&&& &&& &/connection&
&&& &&& &developerConnection&
&&& &&& &&& scm:svn:/banseon/maven/banseon/dao-trunk
&&& &&& &/developerConnection&
&&& &&& &url&/banseon&/url&
&&& &/scm&
&&& &!-- 用于配置分发管理,配置相应的产品发布信息,主要用于发布,在执行mvn deploy后表示要发布的位置 --&
&&& &distributionManagement&
&&& &&& &!-- 配置到文件系统 --&
&&& &&& &repository&
&&& &&& &&& &id&banseon-maven2&/id&
&&& &&& &&& &name&banseon maven2&/name&
&&& &&& &&& &url&file://${basedir}/target/deploy&/url&
&&& &&& &/repository&
&&& &&& &!-- 使用ssh2配置 --&
&&& &&& &snapshotRepository&
&&& &&& &&& &id&banseon-maven2&/id&
&&& &&& &&& &name&Banseon-maven2 Snapshot Repository&/name&
&&& &&& &&& &url&scp:///banseon:/usr/local/maven-snapshot&/url&
&&& &&& &/snapshotRepository&
&&& &&& &!-- 使用ssh2配置 --&
&&& &&& &site&
&&& &&& &&& &id&banseon-site&/id&
&&& &&& &&& &name&business api website&/name&
&&& &&& &&& &url&
&&& &&& &&& &&& scp:///banseon:/var/www/localhost/banseon-web
&&& &&& &&& &/url&
&&& &&& &/site&
&&& &/distributionManagement&
&&& &!-- 依赖关系 --&
&&& &dependencies&
&&& &&& &dependency&
&&& &&& &&& &groupId&junit&/groupId&
&&& &&& &&& &artifactId&junit&/artifactId&
&&& &&& &&& &version&3.8.1&/version&
&&& &&& &&& &!-- scope 说明
&&& &&& &&& &&& - compile :默认范围,用于编译
&&& &&& &&& &&& - provided:类似于编译,但支持你期待jdk或者容器提供,类似于classpath
&&& &&& &&& &&& - runtime: 在执行时,需要使用
&&& &&& &&& &&& - test:&&& 用于test任务时使用
&&& &&& &&& &&& - system: 需要外在提供相应得元素。通过systemPath来取得
&&& &&& &&& &&& - systemPath: 仅用于范围为system。提供相应的路径
&&& &&& &&& &&& - optional:&& 标注可选,当项目自身也是依赖时。用于连续依赖时使用
&&& &&& &&& --&
&&& &&& &&& &scope&test&/scope&
&&& &&& &&& &!--
&&& &&& &&& &&& - systemPath: 仅用于范围为system。提供相应的路径
&&& &&& &&& &&& - optional: 标注可选,当项目自身也是依赖时。用于连续依赖时使用
&&& &&& &&& --&
&&& &&& &&& &!--
&&& &&& &&& &&& &type&jar&/type&
&&& &&& &&& &&& &optional&true&/optional&
&&& &&& &&& --&
&&& &&& &/dependency&
&&& &&& &!--
&&& &&& &&& - 外在告诉maven你只包括指定的项目,不包括相关的依赖。此因素主要用于解决版本冲突问题
&&& &&& &&& - 如下依赖表示 项目acegi-security依赖 org.springframework.XXX 项目,但我们不需要引用这些项目
&&& &&& --&
&&& &&& &dependency&
&&& &&& &&& &groupId&org.acegisecurity&/groupId&
&&& &&& &&& &artifactId&acegi-security&/artifactId&
&&& &&& &&& &version&1.0.5&/version&
&&& &&& &&& &scope&runtime&/scope&
&&& &&& &&& &exclusions&
&&& &&& &&& &&& &exclusion&
&&& &&& &&& &&& &&& &artifactId&spring-core&/artifactId&
&&& &&& &&& &&& &&& &groupId&org.springframework&/groupId&
&&& &&& &&& &&& &/exclusion&
&&& &&& &&& &&& &exclusion&
&&& &&& &&& &&& &&& &artifactId&spring-support&/artifactId&
&&& &&& &&& &&& &&& &groupId&org.springframework&/groupId&
&&& &&& &&& &&& &/exclusion&
&&& &&& &&& &&& &exclusion&
&&& &&& &&& &&& &&& &artifactId&commons-logging&/artifactId&
&&& &&& &&& &&& &&& &groupId&commons-logging&/groupId&
&&& &&& &&& &&& &/exclusion&
&&& &&& &&& &&& &exclusion&
&&& &&& &&& &&& &&& &artifactId&spring-jdbc&/artifactId&
&&& &&& &&& &&& &&& &groupId&org.springframework&/groupId&
&&& &&& &&& &&& &/exclusion&
&&& &&& &&& &&& &exclusion&
&&& &&& &&& &&& &&& &artifactId&spring-remoting&/artifactId&
&&& &&& &&& &&& &&& &groupId&org.springframework&/groupId&
&&& &&& &&& &&& &/exclusion&
&&& &&& &&& &/exclusions&
&&& &&& &/dependency&
&&& &&& &dependency&
&&& &&& &&& &groupId&org.springframework&/groupId&
&&& &&& &&& &artifactId&spring&/artifactId&
&&& &&& &&& &version&2.5.1&/version&
&&& &&& &&& &scope&runtime&/scope&
&&& &&& &/dependency&
&&& &&& &dependency&
&&& &&& &&& &groupId&org.springframework&/groupId&
&&& &&& &&& &artifactId&spring-web&/artifactId&
&&& &&& &&& &version&2.5.1&/version&
&&& &&& &&& &scope&runtime&/scope&
&&& &&& &/dependency&
&&& &&& &dependency&
&&& &&& &&& &groupId&postgresql&/groupId&
&&& &&& &&& &artifactId&postgresql&/artifactId&
&&& &&& &&& &version&8.2-504.jdbc4&/version&
&&& &&& &&& &scope&runtime&/scope&
&&& &&& &/dependency&
&&& &&& &dependency&
&&& &&& &&& &groupId&com.oracle&/groupId&
&&& &&& &&& &artifactId&ojdbc6&/artifactId&
&&& &&& &&& &version&11.1.0.6&/version&
&&& &&& &&& &scope&runtime&/scope&
&&& &&& &/dependency&
&&& &/dependencies&
&&& &&& - maven proxy, 本地仓库,替代 maven.apache.org 网站 jar 列表,用户下载时,首先寻找该站点
&&& &&& - 如资源找到,则下载。否则才去 jar 列表网站。对多人团队,可节省下载速度和个人存储空间。
&&& &repositories&
&&& &&& &repository&
&&& &&& &&& &id&banseon-repository-proxy&/id&
&&& &&& &&& &name&banseon-repository-proxy&/name&
&&& &&& &&& &url&http://192.168.1.169:9999/repository/&/url&
&&& &&& &&& &layout&default&/layout&
&&& &&& &/repository&
&&& &/repositories&
maven的pom配置可以参看下面的这个
&dependency&
&&&& &groupId&com.ibm&/groupId&
&&&& &artifactId&com.ibm.mqjms&/artifactId&
&&&& &version&5.3.07&/version&
&/dependency&
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:29888次
排名:千里之外
原创:32篇
转载:25篇
(2)(1)(1)(1)(1)(3)(2)(2)(1)(1)(3)(3)(2)(7)(2)(8)(4)(8)(5)Maven系列--pom.xml 配置详解_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
喜欢此文档的还喜欢
Maven系列--pom.xml 配置详解
阅读已结束,如果下载本文需要使用
想免费下载本文?
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢锁定老帖子
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
发表时间:&&
说完了settings.xml配置,下来说一下maven2的主要配置pom.xml
什么是pom?
pom作为项目对象模型。通过xml表示maven项目,使用pom.xml来实现。主要描述了项目:包括配置文件;开发者需要遵循的规则,缺陷管理系统,组织和licenses,项目的url,项目的依赖性,以及其他所有的项目相关因素。
快速察看:
基本内容:
POM包括了所有的项目信息。
maven 相关:
pom定义了最小的maven2元素,允许groupId,artifactId,version。所有需要的元素
groupId:项目或者组织的唯一标志,并且配置时生成的路径也是由此生成,如org.codehaus.mojo生成的相对路径为:/org/codehaus/mojo
artifactId: 项目的通用名称
version:项目的版本
packaging: 打包的机制,如pom, jar, maven-plugin, ejb, war, ear, rar, par
classifier: 分类
主要为依赖,继承,合成
依赖关系:
groupId, artifactId, version:描述了依赖的项目唯一标志
可以通过以下方式进行安装:
使用以下的命令安装:
mvn install:install-file –Dfile=non-maven-proj.jar –DgroupId=some.group –DartifactId=non-maven-proj –Dversion=1
创建自己的库,并配置,使用deploy:deploy-file
设置此依赖范围为system,定义一个系统路径。不提倡。
type:相应的依赖产品包形式,如jar,war
scope:用于限制相应的依赖范围,包括以下的几种变量:
compile :默认范围,用于编译
provided:类似于编译,但支持你期待jdk或者容器提供,类似于classpath
runtime:在执行时,需要使用
test:用于test任务时使用
system:需要外在提供相应得元素。通过systemPath来取得
systemPath: 仅用于范围为system。提供相应的路径
optional: 标注可选,当项目自身也是依赖时。用于连续依赖时使用
外在告诉maven你只包括指定的项目,不包括相关的依赖。此因素主要用于解决版本冲突问题
org.apache.maven
maven-embedder
org.apache.maven
maven-core
表示项目maven-embedder需要项目maven-core,但我们不想引用maven-core
另一个强大的变化,maven带来的是项目继承。主要的设置:
定义父项目
org.codehaus.mojo
packaging 类型,需要pom用于parent和合成多个项目。我们需要增加相应的值给父pom,用于子项目继承。主要的元素如下:
开发者和合作者
插件执行使用相应的匹配ids
子项目配置
org.codehaus.mojo
../my-parent
my-project
relativePath可以不需要,但是用于指明parent的目录,用于快速查询。
dependencyManagement:
用于父项目配置共同的依赖关系,主要配置依赖包相同因素,如版本,scope。
合成(或者多个模块)
一个项目有多个模块,也叫做多重模块,或者合成项目。
如下的定义:
org.codehaus.mojo
my-project1
my-project2
build 设置
主要用于编译设置,包括两个主要的元素,build和report
主要分为两部分,基本元素和扩展元素集合
注意:包括项目build和profile build
${basedir}/target
${artifactId}-${version}
filters/filter1.properties
defaultGoal: 定义默认的目标或者阶段。如install
directory: 编译输出的目录
finalName: 生成最后的文件的样式
filter: 定义过滤,用于替换相应的属性文件,使用maven定义的属性。设置所有placehold的值
资源(resources)
你项目中需要指定的资源。如spring配置文件,log4j.properties
META-INF/plexus
${basedir}/src/main/plexus
configuration.xml
**/*.properties
resources: resource的列表,用于包括所有的资源
targetPath: 指定目标路径,用于放置资源,用于build
filtering: 是否替换资源中的属性placehold
directory: 资源所在的位置
includes: 样式,包括那些资源
excludes: 排除的资源
testResources: 测试资源列表
在build时,执行的插件,比较有用的部分,如使用jdk 5.0编译等等
org.apache.maven.plugins
maven-jar-plugin
extensions: true or false,是否装载插件扩展。默认false
inherited: true or false,是否此插件配置将会应用于poms,那些继承于此的项目
configuration: 指定插件配置
dependencies: 插件需要依赖的包
executions: 用于配置execution目标,一个插件可以有多个目标。
maven-antrun-plugin
Build Dir: ${project.build.directory}
id:规定execution 的唯一标志
goals: 表示目标
phase: 表示阶段,目标将会在什么阶段执行
inherited: 和上面的元素一样,设置false maven将会拒绝执行继承给子插件
configuration: 表示此执行的配置属性
pluginManagement:插件管理以同样的方式包括插件元素,用于在特定的项目中配置。所有继承于此项目的子项目都能使用。主要定义插件的共同元素
扩展元素集合
主要包括以下的元素:
Directories
用于设置各种目录结构,如下:
${basedir}/src/main/java
${basedir}/src/main/scripts
${basedir}/src/test/java
${basedir}/target/classes
${basedir}/target/test-classes
Extensions
表示需要扩展的插件,必须包括进相应的build路径。
org.apache.maven.wagon
1.0-alpha-3
用于在site阶段输出报表。特定的maven 插件能输出相应的定制和配置报表。
${basedir}/target/site
maven-project-info-reports-plugin
Report Sets
用于配置不同的目标,应用于不同的报表
/j2se/1.5.0/docs/api/
有思想的芦苇
等级: 初级会员
来自: 大连
发表时间:&&
请问楼主如果Junit的测试代码需要调用一批配置文件,它们基本处于一个大目录中,是否需要用&testResources&来处理,能给出一个简单sample吗?
请登录后投票
发表时间:&&
默认放在test 下面的resources中就行了。如果需要自定义,更改 &testResources&&&&&& &testResource&&&&&&&& &directory&src/test/yourresources&/directory&&&&&& &/testResource&&&& &/testResources&
请登录后投票
等级: 初级会员
来自: 合肥
发表时间:&&
that's ok!
请登录后投票
跳转论坛:移动开发技术
Web前端技术
Java企业应用
编程语言技术maven的pom.xml如何配置成本地的tomcat?_小组_ThinkSAAS
maven的pom.xml如何配置成本地的tomcat?
maven的pom.xml如何配置成本地的tomcat?
创建appfuse时,我想把pom.xml中tomcat配置成我本地已经装好的,默认会下个tomcat6,我想让它直接用我的.
&!-- Cargo settings--&&cargo.container&tomcat5x&/cargo.container&&cargo.container.home&${env.CATALINA_HOME}
&/cargo.container.home&
&cargo.container.url&http:&cargo.host&localhost&/cargo.host&&cargo.port&8081&/cargo.port&&cargo.wait&false&/cargo.wait&请给说说xml怎么修改,保留或直接干掉这段都报错. 第一次尝试这个,谢谢
用户评论(0)
开发技术学习小组列表
PHP开发框架
缓存Memcache
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
手机客户端
ThinkSAAS接收任何功能的Iphone(IOS)和Android手机的客户端定制开发服务
让ThinkSAAS更好,把建议拿来。
iphone扫码下载客户端}

我要回帖

更多关于 maven的pom.xml 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信