博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
怎样编写maven parent pom 文件
阅读量:6144 次
发布时间:2019-06-21

本文共 2558 字,大约阅读时间需要 8 分钟。

parent pom 定义你的项目模型,包括构建方式,项目环境,项目依赖,输出JavaDoc,发布source源码等等,怎样去编写一份parent pom,这里是一个现成的并正在某些项目中使用到的:

peaceful-basic-platform

A best global parent pom file , you can use it in jar or war project as your maven parent pom setting

com.peaceful
peaceful-parent
1.0-SNAPSHOT

peaceful-parent

The basic configuration for build setting

  1. project build coding:UTF-8

  2. maven repositories:repo2

  3. default profiles: devtestproduct. The pom think project should has three running env or build env:dev、test、product. you can specify the environment by :

    `mvn -Penv[test][product]  compile[deploy][jetty:run]`

    The default env is dev, you can get the env value in pom by ${project.environment} and in Java code by invoke Application.getRunningMode()

setting build plugin

  1. buildnumber-maven-plugin:1.3 phase:validate desc:use timestamp as build version,you can get the version value by ${timestamp}

    in pom.xml and get the value in Java code by invoke Application.getBuildVersion()

  2. maven-jar-plugin:2.6

  3. maven-compiler-plugin:3.3

  4. maven-war-plugin:2.0.2

  5. maven-resources-plugin:2.7

  6. maven-source-plugin:2.4 phase:deploy

  7. maven-javadoc-plugin:2.9.1 phase:deploy

  8. maven-surefire-plugin:2.7 desc: default skip test

  9. yuicompressor-maven-plugin:1.5.0 desc:compress style file: .js .css

  10. jetty-maven-plugin:8.1.8.v20121106 desc: start web project in jetty, default port 8888,you can change web port in your pom to override Settings

    9999
    8888

setting dependencies

  1. log:slf4j log4j perf4j

  2. test:junit

  3. common tools:guava、commons-lang3、httpclient

  4. json:fastjson

  5. web:jstl、javaee-api

  6. db:mysql、c3p0

  7. framework:spring、springMvc、mybatis

peaceful-common-utils

Cooperate with the parent pom configuration files, can read building basic information, such as building time, version number, running environment of the project

The parent pom define 3 kinds of profile:devtestproduct。If your project use the pom as parent pom,you need add peaceful-common-utils dependency in your pom file.

com.peaceful
peaceful-common-utils
1.0-SNAPSHOT

The peaceful-common-utils will read your build info into application.properties.

get build version

Application.getVersion()

get running mode

Application.getRunningMode()...Application.isTest()Application.isProduct()Application.isDev()

get Running time

# you need invoke Application.loadToJVM() when your application startApplication.getRunningTime()

转载地址:http://wpjya.baihongyu.com/

你可能感兴趣的文章
2019/1/15 批量删除数据库相关数据
查看>>
数据类型的一些方法
查看>>
Mindjet MindManager 2019使用教程:
查看>>
游戏设计的基本构成要素有哪些?
查看>>
详解 CSS 绝对定位
查看>>
AOP
查看>>
我的友情链接
查看>>
NGUI Label Color Code
查看>>
.NET Core微服务之基于Polly+AspectCore实现熔断与降级机制
查看>>
vue组件开发练习--焦点图切换
查看>>
浅谈OSI七层模型
查看>>
Webpack 2 中一些常见的优化措施
查看>>
移动端响应式
查看>>
python实现牛顿法求解求解最小值(包括拟牛顿法)【最优化课程笔记】
查看>>
js中var、let、const的区别
查看>>
腾讯云加入LoRa联盟成为发起成员,加速推动物联网到智联网的进化
查看>>
从Python2到Python3:超百万行代码迁移实践
查看>>
Windows Server已可安装Docker,Azure开始支持Mesosphere
查看>>
简洁优雅地实现夜间模式
查看>>
react学习总结
查看>>