maven项目配置框架
任何一个maven项目都会继承一个默认的父pom配置:Super POM,详见:https://maven.apache.org/guides/introduction/introduction-to-the-pom.html 。
在pom.xml中可以直接使用一些变量值,如:
${project.groupId} The group id of current project
${project.version} The version of current project
${project.build.sourceDirectory} The source directory of current project
${project.basedir} The directory that the current project resides in.
${project.baseUri} The directory that the current project resides in, represented as an URI. Since Maven 2.1.0
${maven.build.timestamp} The timestamp that denotes the start of the build. Since Maven 2.1.0-M1
详见:https://maven.apache.org/guides/introduction/introduction-to-the-pom.html之Available Variables
一个实际完整的maven项目pom.xml文件配置框架:
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<!-- 模块参数 -->
<artifactId>xxx-xxx</artifactId>
<version>x.x.x</version>
<packaging>war</packaging>
<name>xxx</name>
<url>xxx</url>
<!-- 父模块,可选. -->
<parent>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<version>x.x.x</version>
</parent>
<!-- 定义属性 -->
<properties>
<!-- 项目编码 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 时间格式 -->
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
</properties>
<!-- 依赖配置 -->
<dependencies>
<dependency>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<version>x.x.x</version>
</dependency>
</dependencies>
<!-- 定义profile: 将开发配置和生产配置分离开 -->
<profiles>
<profile>
<id>dev</id>
<properties>
<profile.dir>dev</profile.dir>
</properties>
<activation>
<activeByDefault>dev</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<profile.dir>test</profile.dir>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<profile.dir>prod</profile.dir>
</properties>
</profile>
</profiles>
<!-- 打包 -->
<build>
<finalName>xxx</finalName>
<!-- 打包资源 -->
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>.svn</exclude>
<exclude>.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources/profiles/${profile.dir}</directory>
<excludes>
<exclude>.svn</exclude>
</excludes>
</resource>
</resources>
<!-- 配置打包插件,如: 依赖处理,资源复制,压缩打包等 -->
<plugins>
<!-- 生成jar包时打包资源文件配置 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<excludes>
<exclude>**/profiles/**</exclude>
<exclude>**/jdbc.properties</exclude>
<exclude>**/*.proto</exclude>
</excludes>
</configuration>
</plugin>
<!-- 打包源码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 打包编译参数 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- 将依赖模块的jar包文件提取出来放到指定位置 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.xxx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0.0</version>
<type>jar</type>
<includes>**/*.class</includes>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- 打包可执行jar文件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.chench.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- 构建时不执行单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
maven项目配置框架的更多相关文章
- maven项目配置findbugs插件 使用git钩子控制代码的提交
maven项目配置findbugs插件对代码进行静态检测 当发现代码有bug时,就不让用户commit代码到远程仓库里 没有bug时才可以commit到远程仓库中 (1)新建maven项目 ,配置fi ...
- maven项目配置使用jdk1.8进行编译的插件
在使用Maven插件编译Maven项目的时候报了这样一个错:[Java source1.5不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符],这里记录下出现这个错 ...
- maven项目ssh框架的整合
1.环境 eclipse版本:Eclipse Mars2 4.5jdk版本:1.8maven版本:apache-maven 3.3.9zhnegs这是主要的开发工具版本,ssh的各种jar包版本就不列 ...
- maven项目快速搭建SSM框架(一)创建maven项目,SSM框架整合,Spring+Springmvc+Mybatis
首先了解服务器开发的三层架构,分配相应的任务,这样就能明确目标,根据相应的需求去编写相应的操作. 服务器开发,大致分为三层,分别是: 表现层 业务层 持久层 我们用到的框架分别是Spring+Spri ...
- maven 项目配置
创建java web的maven项目方法有两种,一是先创建maven项目,再选择jdk 和 dynamic web 运行环境 ,二是创建java项目,然后转化为maven项目 1.将普通java项目转 ...
- apache log4j日志工具使用入门[maven 项目配置]
简单的介绍下Maven项目中有关org.apache.log4j.Logger的使用.[1]首先我们需要找到 org.apache.log4j.Logger的坐标,并配置到POM.xml <de ...
- 【IDEA】本地新建Maven项目+配置Git和GitHub+代码上传和拉取到GitHub+其他IDEA和GitHub实战
一.本地新建Maven项目并启动成功 1. 按照IDEA提供的模板,构建一个maven webapp的模板项目. 一路Next,到最后的finish.如下图. 2. 新建Tomcat,启动刚建立的项目 ...
- Maven项目配置Logback输出JSON格式日志
最近,项目提出需求,日志需要固定输出为JSON格式,以便后端Flink程序解析. 项目背景 项目为简单的Maven项目,日志由Filebeat采集,因此不需要配置输出至Logstash. 下面为pom ...
- maven 项目配置到tomcat不能正常启动
最近使用IntelliJ IDEA搭建公司项目,该项目是maven项目,加载jar和编译的时候没有任何异常,但是部署到tomcat上之后,就会出现如下异常: org.apache.catalina.L ...
随机推荐
- while(~scanf(..))为什么可以这样写
因为读到文件的结束符时,scanf返回值是EOF,也就是-1,而~(-1)的作用就是对-1的按位取反. 在计算机中,数字按补码存储,正数的补码和原码一样,负数的补码是其反码+1,反码也就是符号位仍为1 ...
- Outsider(HNOI2019)
这不是一篇退役记,因为NOIP2018之后就写完了. Day-1 清明时节雨纷纷. 最后的时光,应该是怎么样的呢? 是像水滴一样,悄无声息地从指缝中溜走 还是如火焰一般,燃烧着最后的留恋? 晚上一直在 ...
- 树状数组区间加法&区间求和操作
树状数组区间加法&区间求和操作 一般的树状数组解决区间加&单点询问并不复杂 但是要解决区间求和... 我们假设原数组是\(\{a_i\}\),差分数组\(\{d_i=a_i-a_{i- ...
- poj3926 parade (单调队列+dp)
题意:有n行路,每行路被分成m段,每一段有长度和权值,要求从最下面一行走到最上面一行某个位置,可以从相邻两行的同一列交点往上走,并且在同一行走的长度要<=K,求走过的最大权值 设f[i][j]为 ...
- LOJ#510 北校门外的回忆(找性质+倍增+线段树)
这题一场模拟赛我们出了弱化版(n<=1e6),抄题面给的程序能拿到71分的好成绩 其实后面的29分是加了几个1e9的数据卡人 这糟老头子真是坏得很 正解我们机房看了三天 在这里感谢这篇题解的作者 ...
- Can DBC文件翻译
1 引言 DBC文件描述单个CAN网络的通信.这个信息足以监测和分析网络并模拟不是物理可用的节点(剩余的总线模拟). DBC文件也可以用来开发电子控制单元的通信软件,该控制单元应该是CAN网络的一部分 ...
- Up-to-date cache with EclipseLink and Oracle
Up-to-date cache with EclipseLink and Oracle One of the most useful feature provided by ORM librarie ...
- 通过WebChannel/WebSockets与QML中的HTML交互
来源:通过WebChannel/WebSockets与QML中的HTML交互 GitHub:八至 作者:狐狸家的鱼 本文链接:QML与HTML交互 在查询QML与HTML之间通信交互时资料很少,这篇文 ...
- Spring boot学习笔记之@SpringBootApplication注解
@SpringBootApplication(exclude = SessionAutoConfiguration.class) public class BootReactApplication { ...
- (转)ZooKeeper的Znode剖析
ZooKeeper的Znode剖析 https://blog.csdn.net/lihao21/article/details/51810395 根据节点的存活时间,可以对节点划分为持久节点和临时节点 ...