这里只记了学习以下博客后,自己做的一个总结。

来源:http://blog.csdn.net/fengchao2016/article/details/72726101

profiles定义了一些不同类型的变量,在这些变量中处于激活状态的才会被真正使用,填充到resources指定的文件中的${},或者filter中书写的路径的${} 里去。

filters定义了一些过滤规则,就是一些文件路径,其下的filter写什么那么就保留什么,剩余的就会被忽视

resources定义了一些目录,也就是被过滤的目录

以上三者共同定义了那些文件需要发布到编译目标目录下,以及文件中的${}的内容应该替换成什么

其它参考:http://jjhpeopl.iteye.com/blog/2325375

最后奉上一个自己做的测试maven pom的项目,pom里面加了一些常见的maven plugin,并且有详细注释内容如下:

里面就3个文件:

Main.java

package com.liuyx;

import java.util.List;

import com.google.common.collect.Lists;

public class Main {

    public Main() {
List<String> l = Lists.newArrayList("hello");
for(String s:l) {
System.out.println(s);
} }
}

config.properties

${a}:${b}

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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.maven</groupId>
<artifactId>testMaven</artifactId>
<version>0.0.1-SNAPSHOT</version> <dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>
</dependencies> <profiles>
<!-- mvn help:active-profiles 查询当前激活的profile -->
<!-- 1、手动激活,直接使用命令指定id mvn package -P test -->
<profile>
<id>test</id>
<properties>
<!-- 这两个可以替换config.properties中的内容 -->
<a>key-test</a>
<b>value-test</b>
<config.name>config.properties</config.name><!-- 这个可以替换filter中的内容 -->
</properties>
<activation>
<!-- 设为默认激活,不设置则默认激活的id为dev -->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>byfile</id>
<properties>
<a>key-file</a>
<b>value-file</b>
</properties>
<activation>
<!-- 2、根据文件存在来决定是否激活 -->
<file>
<exists>config-file.properties</exists>
</file>
</activation>
</profile>
<profile>
<id>byjdk</id>
<properties>
<a>key-jdk</a>
<b>value-jdk</b>
</properties>
<activation>
<!-- 3、根据jdk环境来决定是否激活 -->
<jdk>1.9</jdk>
</activation>
</profile>
<profile>
<id>byos</id>
<properties>
<a>key-os</a>
<b>value-os</b>
</properties>
<activation>
<!-- 4、根据操作系统环境来决定是否激活 -->
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
<version>5.1.2600</version>
</os>
</activation>
</profile>
</profiles> <build>
<!-- 编译后的jar包名称 -->
<finalName>one-maven-test</finalName> <filters> <!-- 指定 filter内容,用来过滤resource下的内容 -->
<filter>src/main/resources/${config.name}</filter>
</filters> <resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<!-- 设为true则用上激活的profile -->
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
</includes>
<targetPath>${project.build.directory}/config</targetPath>
</resource>
</resources> <!-- 几个常用插件,更多插件请自行搜索 maven plugin -->
<plugins>
<!-- 编译插件,一般用于指定使用的java版本,不过也可以直接在properties中配置
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin> <!-- 用来复制依赖的jar包到指定目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<configuration>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin> <!-- 打成jar包时用来指定MANIFEST.MF文件中的Main class和classpath mainfest等内容 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<!-- 是否增加maven描述信息 -->
<addMavenDescriptor>false</addMavenDescriptor> <!-- 批量处理 -->
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.liuyx.Main</mainClass>
<!-- Implementation:实现 -->
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<!-- Specification:规格说明书 -->
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<!-- 部分内容无法批量处理,手动添加,这里把.和libs/都添加到了 classpath中 -->
<manifestEntries>
<Class-Path>.</Class-Path>
<Class-Path>libs/</Class-Path>
<Permissions>${Permissions}</Permissions>
<Caller-Allowable-Codebase>${Caller-Allowable-Codebase}</Caller-Allowable-Codebase>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

maven profiles、filters、resources学习笔记 及 常用 plugin demo的更多相关文章

  1. python3.4学习笔记(十) 常用操作符,条件分支和循环实例

    python3.4学习笔记(十) 常用操作符,条件分支和循环实例 #Pyhon常用操作符 c = d = 10 d /= 8 #3.x真正的除法 print(d) #1.25 c //= 8 #用两个 ...

  2. python3.4学习笔记(六) 常用快捷键使用技巧,持续更新

    python3.4学习笔记(六) 常用快捷键使用技巧,持续更新 安装IDLE后鼠标右键点击*.py 文件,可以看到Edit with IDLE 选择这个可以直接打开编辑器.IDLE默认不能显示行号,使 ...

  3. Python学习笔记之常用函数及说明

    Python学习笔记之常用函数及说明 俗话说"好记性不如烂笔头",老祖宗们几千年总结出来的东西还是有些道理的,所以,常用的东西也要记下来,不记不知道,一记吓一跳,乖乖,函数咋这么多 ...

  4. java web jsp学习笔记--概述-常用语法,指令,动作元素,隐式对象,域对象

     JSP学习笔记 1.什么是jsp JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术.JSP/Servlet规范.JS ...

  5. git学习笔记:常用命令总结

    本文根据廖雪峰的博客,记录下自己的学习笔记.主要记录常用的命令,包括仓库初始化.添加文件.提交修改.新建分支.内容暂存.分支管理.标签管理等内容. git是分布式版本控制系统. 首先是安装,从官网下载 ...

  6. python自动化测试学习笔记-5常用模块

    上一次学习了os模块,sys模块,json模块,random模块,string模块,time模块,hashlib模块,今天继续学习以下的常用模块: 1.datetime模块 2.pymysql模块(3 ...

  7. [原创]java WEB学习笔记30:Cookie Demo 之显示最近浏览的记录

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  8. [原创]java WEB学习笔记29:Cookie Demo 之自动登录

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  9. [Python] Python学习笔记之常用模块总结[持续更新...]

    作为一种极其简单的编程语言,Python目前成为了最炙手可热的几种语言之一.它不仅简单易学,而且它还为用户提供了各种各样的模块,功能强大,无所不能.有利必有弊,学习Python同样有困扰,其中之一就是 ...

随机推荐

  1. MVC使用Dotnet.HighCharts做图表01,区域图表

    如果想在MVC中使用图表显示的话,DotNet.HighCharts是不错的选择.DotNet.HighCharts是一个开源的JavaScript图表库,支持线型图表.柱状图标.饼状图标等几十种图标 ...

  2. python文本 字符串逐字符反转以及逐单词反转

    python文本 字符串逐字符反转以及逐单词反转 场景: 字符串逐字符反转以及逐单词反转 首先来看字符串逐字符反转,由于python提供了非常有用的切片,所以只需要一句就可以搞定了 >>& ...

  3. arcgis10.5新功能图形缓冲

    摘要 在输入要素周围某一指定距离内创建缓冲区多边形.在要素周围生成缓冲区时,大部分制图形状对缓冲区末端(端头)和拐角(连接)可用. 插图  

  4. 【docker-compose】docker-compose.yml文本内容详解 + docker-compose命令详解 + docker-compose启动服务容器时区设置

    参考地址:https://blog.csdn.net/Kiloveyousmile/article/details/79830810 参考地址:https://docs.docker.com/comp ...

  5. Ubuntu安装Oracle时出现乱码,及其他安装错误

    只要在运行./runInstaller之前先运行下以下命令就ok了: export LANG=en_US #设置运行语言 编译错误 ln -s /usr/lib/i386-linux-gnu/libp ...

  6. [GIT] Git 工作流程(Git flow, Github flow flow, Git lab flow)

    reference : http://www.ruanyifeng.com/blog/2015/12/git-workflow.html Git 作为一个源码管理系统,不可避免涉及到多人协作. 协作必 ...

  7. C语言:通过函数指针来完成两个数的加减乘除(函数指针当做参数使用)

    // //  main.c //  Function_pointer // //  Created by mac on 15/8/2. //  Copyright (c) 2015年. All rig ...

  8. 数学图形(1.45)毛雷尔玫瑰(Maurer rose)

    毛雷尔玫瑰,也有的翻译是毛瑞尔,它是一种很漂亮的图形.玫瑰线的变异品种. 我没有找到其中文的解释,有兴趣可以看下维基上的相关页面. A Maurer rose of the rose r = sin( ...

  9. Informatica 常用组件Lookup缓存之五 使用动态查找高速缓存

    对于关系查找,当目标表也是查找表时,可能要配置转换以使用动态高速缓存.PowerCenter 将在处理第一个查找请求时创建高速缓存.它将根据查找条件为传递给转换的每行查询高速缓存.当您使用动态高速缓存 ...

  10. MVC 与 MVP 架构 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...