Maven实战(八)pom.xml简介

  目录

pom作为项目对象模型。通过xml表示maven项目,使用pom.xml来实现。主要描述了项目:包括配置文件、开发者需要遵循的规则、缺陷管理系统、组织和licenses、项目的url、项目的依赖性以及其他所有的项目相关因素。

下面是我在项目中应用的一个pom.xml,仅供参考

更多细节内容将在后面的章节中一一讲解

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!-- 继承父类 -->
    <parent>
        <!-- 坐标 -->
        <groupId>com.shiyue.sysesp</groupId>
        <artifactId>sysesp-core-parent</artifactId>
        <version>1.0.CR11</version>
        <relativePath>../sysesp-core-parent/pom.xml</relativePath>
    </parent>
    <artifactId>sysesp-core-web</artifactId>
    <!-- jar/war/ear -->
    <packaging>war</packaging>
    <url>http://maven.apache.org</url>
                                                      
    <!-- 依赖jar包 -->
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.shiyue.sysesp</groupId>
            <artifactId>sysesp-core-service</artifactId>
        </dependency>
        <!-- Struts2.3.4 -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-json-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
        </dependency>
        <!-- Servlet API -->
        <dependency>
            <groupId>com.shiyuesoft</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.shiyuesoft</groupId>
            <artifactId>jsp-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- JSTL -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <!-- Spring web -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>jxl</groupId>
            <artifactId>jxl</artifactId>
        </dependency>
        <!-- 分页 -->
        <dependency>
            <groupId>com.sysesp.tag</groupId>
            <artifactId>tag</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jasig.cas.client</groupId>
            <artifactId>cas-client-core</artifactId>
        </dependency>
    </dependencies>
                                                      
    <!-- build相关 -->
    <build>
        <!-- 打包后的名称 -->
        <finalName>base</finalName>
                                                          
        <!-- 插件 -->
        <plugins>
            <!-- war包插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                  <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>
                            <includes>
                                <include>WEB-INF/web.xml</include>
                                <include>WEB-INF/log4j.properties</include>
                            </includes>
                        </resource>                  
                    </webResources>
                </configuration>
            </plugin>
            <!-- 部署插件,自动部署至远程tomcat -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <url>http://192.168.2.203:8080/manager/text</url>
                    <path>/${build.finalName}</path>
                    <username>bruce</username>
                    <password>bruce</password>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
posted @ 2015-02-09 17:45  风过无痕的博客  阅读(717)  评论(0编辑  收藏  举报