MAVEN学习(2):用例子来理解打包原理

来源:互联网 发布:处理大规模结构化数据 编辑:程序博客网 时间:2024/06/03 23:44

1.pom.xml

pom是什么,,,见上一篇把。
这个配置文件是用来描述Maven项目的。来个最简单的例子

<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">  <modelVersion>4.0.0</modelVersion>  <groupId>com.gwb</groupId>  <artifactId>ss</artifactId>  <version>0.0.1-SNAPSHOT</version>  <packaging>jar</packaging>  <name>ss</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>    </dependency>  </dependencies></project>

gourpid artifactid version 都是最基本的Mvaen坐标。
Dependencies模块呢。是依赖的管理,注意这里有个依赖传递的概念。这个例子说明了依赖Junit这个jar包,把资源包引入本地仓库,scope是作用范围,test指这个jar包只在Maven测试的时候才会用。

摘自:http://uule.iteye.com/blog/2078925?utm_source=tuicool
上面这个就是最普通的maven项目的打包。执行mvn clean package 然后mvn installhgj,thttp://uule.iteye.com/blog/2078925?utm_source=tuicool

原创粉丝点击