zoukankan      html  css  js  c++  java
  • Maven配置浅析

    <?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>
    
        <!-- 引入父包 -->
        <parent>
            <groupId>xxx.common</groupId>
            <artifactId>xxx-supom-generic</artifactId>
            <version>1.2.32</version>
        </parent>
    
        <!-- 包名 -->
        <groupId>com.xxx.fresh</groupId>
        <!-- 工程名 -->
        <artifactId>maventest</artifactId>
        <!-- 工程版本号 -->
        <version>1.0.0</version>
        <!-- 工程打包类型 jar war -->
        <packaging>war</packaging>
    
        <!-- dependencyManagement 用于规定jar包version和scope,实际上并不会下载jar包 -->
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>4.1.0</version>
                    <!-- scope(使用范围),默认为compile, 编译时加载包,会下载到本地repo -->
                    <!-- provided, 使用容器提供的包,代码中的包不会被打包发布,比如servlet, 因为如果使用compile开发包与容器包不一致,部署后则会有问题 -->
                    <!-- runtime, jar包在打包的时候打包进去,本地代码不能引用,运行时再加载-->
                    <!-- test, 只能在test中使用 -->
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
        <!-- 实际上会下载的jar包,如果不填写version和scope,则默认使用dependencyManagement规定的version和scope -->
        <dependencies>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>14.0</version>
                <!-- 重复类检测 mvn enforcer:enforce -->
                <!-- 查看项目依赖 mvn dependency:tree -->
                <!-- exclusions的作用是假如guava里使用了log4j,而我们自己的代码也使用了log4j,
                    那么使用了这两个log4j的代码引用的api可能不是一个版本,为了避免兼容性问题,
                    我们可以排除guava中使用的log4j版本,而强制使用我们代码中定义的log4j版本 -->
                <exclusions>
                    <!-- 排除重复包 -->
                    <exclusion>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    
        <build>
            <resources>
                <!-- 规定使用的资源文件的地址,其中${deploy.type}是变量,在profile中定义 -->
                <resource>
                    <directory>src/main/resources.${deploy.type}</directory>
                </resource>
                <resource>
                    <directory>src/main/resources</directory>
                </resource>
            </resources>
        </build>
    
        <!-- 定义变量 -->
        <profiles>
            <profile>
                <id>beta</id>
                <properties>
                    <deploy.type>beta</deploy.type>
                </properties>
            </profile>
            <profile>
                <id>dev</id>
                <properties>
                    <deploy.type>dev</deploy.type>
                </properties>
            </profile>
        </profiles>
    </project>
  • 相关阅读:
    Java MD5机密算法的使用
    JavaWeb学习总结-12 JSTL标签语言
    HTML5学习总结-09 拖放和手机触屏事件
    HTML5学习总结-08 应用缓存(Application Cache)
    HTML5学习总结-08 WebSocket 服务器推送
    软件架构阅读笔记06
    软件架构阅读笔记05
    软件架构阅读笔记04
    软件架构阅读笔记03
    软件架构阅读笔记02
  • 原文地址:https://www.cnblogs.com/zemliu/p/3186483.html
Copyright © 2011-2022 走看看