maven学习——认识pom文件

来源:互联网 发布:java中迭代器的使用 编辑:程序博客网 时间:2024/04/27 23:24

因为接触的项目都是maven,所以开始学习了解maven的结构。

Maven世界中,project可以什么都没有,甚至没有代码,但是必须包含pom.xml文件。它包含了所有与这个项目相关的东西

一个Project往往包含一个配置文件,包括了与开发者有关的,缺陷跟踪系统,组织与许可,项目的URL,项目依赖,以及其他东西。

1.一个POM项目中的pom.xml文件中包含的元素

a.基本项目信息

b.项目构建build

c.基本设置

d.构建环境设置


<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>...</groupId>    <artifactId>...</artifactId>    <version>...</version>    <packaging>...</packaging>    <dependencies>...</dependencies>    <parent>...</parent>    <dependencyManagement>...</dependencyManagement>    <modules>...</modules>    <properties>...</properties>        <!-- 构建过程的设置 -->    <build>...</build>    <reporting>...</reporting>        <!-- 项目信息设置 -->    <name>...</name>    <description>...</description>    <url>...</url>    <inceptionYear>...</inceptionYear>    <licenses>...</licenses>    <organization>...</organization>    <developers>...</developers>    <contributors>...</contributors>        <!-- 环境设置 -->    <issueManagement>...</issueManagement>    <ciManagement>...</ciManagement>    <mailingLists>...</mailingLists>    <scm>...</scm>    <prerequisites>...</prerequisites>    <repositories>...</repositories>    <pluginRepositories>...</pluginRepositories>    <distributionManagement>...</distributionManagement>    <profiles>...</profiles></project>


2.移植和属性过滤

四种移植

1、maven移植-Profiles位于pom.xml

2、maven移植-Profiles位于profiles.xml

3、maven移植-Profiles位于setting.xml

4、maven移植-Profiles(激活方式)



maven属性分五类:
1、project.*
2、settings.*
3、env.*
4、系统属性
5、用户自定义属性




3.标准目录结构:


src
  -main
      –bin 脚本库
      –java java源代码文件
      –resources 资源库,会自动复制到classes目录里
      –filters 资源过滤文件
      –assembly 组件的描述配置(如何打包)
      –config 配置文件
      –webapp web应用的目录。WEB-INF、css、js等
  -test
      –java 单元测试java源代码文件
      –resources 测试需要用的资源库
      –filters 测试资源过滤库
  -site Site(一些文档)
target
LICENSE.txt Project’s license
README.txt Project’s readme

工程根目录下就只有src和target两个目录

target是有存放项目构建后的文件和目录,jar包、war包、编译的class文件等。

target里的所有内容都是maven构建的时候生成的









0 0