Maven使用,POM文件详解

parent

	<parent> 
        <artifactId>xxx</artifactId>
        <groupId>xxx</groupId> 
        <version>xxx</version>
        <relativePath>xxx</relativePath> 
    </parent> 
  • 父项目的pom.xml文件的相对路径,默认值是…/pom.xml。

Maven首先在构建寻找父项目的pom

  • 当前项目的地方
  • 文件系统的这个位置(relativePath位置)
  • 本地仓库
  • 远程仓库寻找父项目的pom

Maven生成构件

   <modelVersion> 4.0.0 </modelVersion> 
   <groupId>xxx</groupId> 
   <artifactId>xxx</artifactId>
   <packaging> jar </packaging>
   <!-- 项目当前版本,格式为:主版本.次版本.增量版本-限定版本号 -->
   <version> 1.0-SNAPSHOT </version> 
   <name> xxx-maven </name> 
   <!-- 项目主页的URL, Maven产生的文档用 --> 
    <url> http://maven.apache.org </url> 

Maven的最低版本要求

<prerequisites> 
             <maven></maven> 
</prerequisites> 

问题管理系统

ciManagement notifiers

项目创建年份,4位数字。当产生版权信息时需要使用这个值 inceptionYear

项目开发者 developers

项目的其他贡献者 contributors

项目所有License列表 licenses

build

<build> 
	<sourceDirectory>源码目录</sourceDirectory> 
	<scriptSourceDirectory>脚本源码目录</scriptSourceDirectory> 
	 <testSourceDirectory>单元测试使用的源码目录</testSourceDirectory> 
	 <outputDirectory>序class文件存放的目录</outputDirectory> 
	 <testOutputDirectory>测试class文件存放的目录</testOutputDirectory> 
	 <extensions> 使用来自该项目的一系列构建扩展
	  <defaultGoal></defaultGoal>当项目没有规定目标默认值
	  <resources> 描述了项目相关的所有资源路径列表
	     - <resource> 
	     -  - <targetPath></targetPath> 
	  <testResources> 单元测试相关的所有资源路径
	  <finalName></finalName>  产生的构件的文件名
	  <filters></filters>使用到的过滤器属性文件列表
	  <pluginManagement> 子项目可以引用的默认插件信息
	  <plugins> 该项目使用的插件列表
	  <dependencies> 项目引入插件所需要的额外依赖

profiles 修改构建处理

<profiles>
    <profile>
            <id>local</id>
            <properties>
                <spring.active>local</spring.active>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <spring.active>test</spring.active>
            </properties>
        </profile>
    </profiles>

modules 子模块

<modules>
      <!--子项目相对路径-->
       <module></module>
 </modules> 

repositories 指定仓库

<repository>
            <id>current-nexus</id>
            <url>http://192.168.10.71:10000/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>nexus-aliyun</id>
            <name>aliyun nexus</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>

dependencyManagement

继承自该项目的所有子项目的默认依赖信息

distributionManagement 发布信息

配置

<properties>
        <name>value</name>
</properties>

Maven添加插件与依赖的区别

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
            <optional>true</optional>
        </dependency>

依赖是项目运行时需要的
插件时项目运行时不需要,打包编译时需要的,比如lombok

<build>
	<plugins>
		<plugin>
		 	<groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
       
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值