您的位置:首页 > 其它

maven的pom.xml的讲解

2016-12-18 21:11 302 查看
<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/xsd/maven-4.0.0.xsd"> <!-- pom的版本号 -->
<modelVersion>4.0.0</modelVersion>
<!--反写公司网址 + 项目名  -->
<groupId>com.misssad.HelloMiss</groupId>
<!-- 项目名 + 模块名 -->
<artifactId>Hi</artifactId>
<!--
第一个 0 大版本号
第二个 0 表示分支版本号
第三个0表示小版本号

snapshot 快照
alpha 内部测试
beta 公测
Release 稳定
GA正式发布
-->
<version>0.0.1-SNAPSHOT</version>
<!-- 默认是jar
war -->
<packaging>jar</packaging>
<!-- 项目名 -->
<name>Hi</name>
<!-- 项目网址 -->
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<!-- 依赖作用域:只对测试代码有效,对主代码无效 -->
<scope>test</scope>
<!-- 排除依赖传递列表 -->
<exclusions>
<exclusion></exclusion>
</exclusions>
</dependency>
</dependencies>
<!--依赖管理 一般用于父模块中
比如吧Junit放到父模块中,让子模块去继承  -->
<dependencyManagement>
<dependencies>
<dependency></dependency>
</dependencies>
</dependencyManagement>
<!--一般是对构建行为进行处理,用的比较多的就是plugins标签
比如下面就使用到了maven的source插件,使其在打包时,
将源码也进行打包-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<!-- 在什么时候执行上面的插件 -->
<executions>
<execution>
<id>attach-sources</id>
<!-- 在打包的时候,执行 -->
<phase>package</phase>
<!-- 执行的目标是打成jar -->
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- 用于子模块中说明继承哪个父模块 -->
<parent>
<groupId>1</groupId>
<artifactId>1</artifactId>
<version>1</version>
</parent>
<!-- 可以同时编译多个模块 -->
<modules>
<module></module>
</modules>
</project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: