zoukankan      html  css  js  c++  java
  • maven项目的pom.xml 标签的含义

    下面是我新建一个maven项目后生产的pom.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <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.zjf.www</groupId>
    <artifactId>maven-webapp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>maven-webapp Maven Webapp</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>1.2.6</version>
    <type>jar</type>
    <url>http://www.springframework.org/</url>
    </dependency>


    </dependencies>

    <build>
    <finalName>maven-webapp</finalName>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
    <plugins>
    <plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>3.0.0</version>
    </plugin>
    <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
    <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.2</version>
    </plugin>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
    </plugin>
    <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
    </plugin>
    <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.2.0</version>
    </plugin>
    <plugin>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
    </plugin>
    <plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>
    </project>

    本人也是是懂非懂,网上查了些资料大概讲述一下。

    <modelVersion>4.0.0</modelVersion>      modelVersion:pom文件的模型版本 为4.0.0

    <groupId>com.zjf.www</groupId>               groupId 组织名称  com.zjf.www 是我创建项目用的文件路径  即公司网址

     <artifactId>maven-webapp</artifactId>      artifactId 项目名称  是我新建的maven项目名称

    <version>0.0.1-SNAPSHOT</version>        version:     artifact模块的版本

    <packaging>war</packaging>                          packaging:项目打包的后缀,war是web项目发布用的,默认为jar

    <name>maven-webapp Maven Webapp</name>    

    <url>http://www.example.com</url>                       name和url:相当于项目描述,可删除

    group id + artifact id +version :项目在仓库中的坐标

    第二部分,引入jar包

    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
    </dependency>
    </dependencies>

    这是创建项目时自动生成的,将junit-4.11.jar引入到项目中。

    <dependencies> 是引入jar包的跟目录 所有引进jar都在这个标签里面 增加<dependency>

    dependency:引入资源jar包到本地仓库,一对dependency标签就引进一个jar包

    同理 group id+artifact id+version:资源jar包在仓库中的坐标

    scope:作用范围,test指该jar包仅在maven测试时使用,发布时会忽略这个包。需要发布的jar包可以忽略这一配置

    第三部分,构建项目

    build:项目构建时的配置

    finalName:在浏览器中的访问路径,如果将它改成helloworld,再执行maven--update,这时运行项目的访问路径是

                       http://localhost:8080/helloworld/   而不是项目名的  http://localhost:8080/test

    plugins:插件

    group id+artifact id+version:插件在仓库中的坐标

    configuration:设置插件的参数值

  • 相关阅读:
    184. Department Highest Salary【leetcode】sql,join on
    181. Employees Earning More Than Their Managers【leetcode】,sql,inner join ,where
    178. Rank Scores【leetcode】,sql
    177. Nth Highest Salary【leetcode】,第n高数值,sql,limit,offset
    176. Second Highest Salary【取表中第二高的值】,sql,limit,offset
    118. Pascal's Triangle【LeetCode】,java,算法,杨辉三角
    204. Count Primes【leetcode】java,算法,质数
    202. Happy Number【leetcode】java,hashSet,算法
    41. First Missing Positive【leetcode】寻找第一个丢失的整数,java,算法
    删除
  • 原文地址:https://www.cnblogs.com/zjf6666/p/9052029.html
Copyright © 2011-2022 走看看