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 ...
随机推荐
- FWT模板(洛谷P4717 【模板】快速沃尔什变换)(FWT)
洛谷题目传送门 只是一个经过了蛇皮压行的模板... 总结?%%%yyb%%% #include<bits/stdc++.h> #define LL long long #define RG ...
- Swarm部署集群
swarm-manager 是 manager node,swarm-worker是 worker node.所有节点的 Docker 版本均不低于 v1.12.在master上 docker swa ...
- Typescript学习笔记(一)基础类型
为了面向ng2和前端未来,开始搞向ts,ts是微软出的一枚语言,作为es6的超集,他出的一些特性还是蛮好用的(略坑).对于我等纯前端(从开始就接触javascript)的人来说,真想说,这特么什么鬼. ...
- jenkins自动打包部署项目
首先去jenkins的官网下载安装包 https://jenkins.io/ 个人下载是长期稳定的那个版本,下载后,得到一个.msi的安装包: 点击进行安装,然后一直点击下一步. jenkins会 ...
- JVM内存模型你只要看这一篇就够了
JVM内存模型你只要看这一篇就够了 我是一只孤傲的鱼鹰 让我们不厌其烦的从内存模型开始说起:作为一般人需要了解到的,JVM的内存区域可以被分为:线程栈,堆,静态方法区(实际上还有更多功能的区域,并且这 ...
- 第三十四节,目标检测之谷歌Object Detection API源码解析
我们在第三十二节,使用谷歌Object Detection API进行目标检测.训练新的模型(使用VOC 2012数据集)那一节我们介绍了如何使用谷歌Object Detection API进行目标检 ...
- Docker下安装Influxdb-1.6.1和Grafana5.2.2
第一步.安装Influxdb 首先启动docker systemctl start docker 然后安装Influxdb(这里解释一下为啥用docker,因为官网下载的话需要FQ[fan-qiang ...
- jenkins学习:jenkins+gitlab
配置前提: 1.Jenkins已安装git plugin,gitlab plugin,安装过程可参考 https://www.cnblogs.com/zhizhiyin/p/9138309.html ...
- Unity 光照着色器
光照着色器需要考虑光照的分类,一般分为漫反射和镜面反射. 漫反射计算基本光照: float brightness=dot(normal,lightDir) 将法线和光的入射方向进行点积运算,求出 ...
- HTTP协议相关原理
HTTP 的全称是 Hyper Text Transfer Protocol,中文名叫做超文本传输协议 HTTP协议是用于从网络传输超文本数据到本地浏览器的传送协议,它能保证传送高效而准确地传送超文本 ...