资讯专栏INFORMATION COLUMN

怎样编写maven parent pom 文件

zzbo / 857人阅读

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

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

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

project build coding:UTF-8

maven repositories:repo2

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

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()

maven-jar-plugin:2.6

maven-compiler-plugin:3.3

maven-war-plugin:2.0.2

maven-resources-plugin:2.7

maven-source-plugin:2.4 phase:deploy

maven-javadoc-plugin:2.9.1 phase:deploy

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

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

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

log:slf4j log4j perf4j

test:junit

common tools:guava、commons-lang3、httpclient

json:fastjson

web:jstl、javaee-api

db:mysql、c3p0

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 start
Application.getRunningTime()

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/64676.html

相关文章

  • Maven 搭建spring boot多模块项目(附源码)

    摘要:搭建多模块项目备注所有项目都在中创建创建项目删除目录,只保留根目录可被子模块继承因此项目只是未考虑太多性能问题所以将诸多依赖都写在根级,子模块只需继承就可以使用。 Maven 搭建spring boot多模块项目 备注:所有项目都在idea中创建 1.idea创建maven项目 1-1: 删除src,target目录,只保留pom.xml 1-2: 根目录pom.xml可被子...

    whatsns 评论0 收藏0
  • Spring Boot 参考指南(开发你的第一个Spring Boot应用程序)

    摘要:开发你的第一个应用程序本节描述如何开发一个简单的应用程序来突出了的一些关键特性,我们使用来构建这个项目,因为大多数都支持它。如果你希望分发一个自包含的应用程序,这可能会有问题。 11. 开发你的第一个Spring Boot应用程序 本节描述如何开发一个简单的Hello World! web应用程序来突出了Spring Boot的一些关键特性,我们使用Maven来构建这个项目,因为大多数...

    Cristalven 评论0 收藏0
  • Spring Boot 参考指南(构建系统)

    摘要:构建系统强烈建议你选择一个支持依赖管理的构建系统,并且可以使用发布到中心存储库的工件。例如,要升级到另一个,你可以将以下元素添加到你的在前面的示例中,我们指定了一个,但是任何依赖类型都可以以相同的方式被覆盖。 13. 构建系统 强烈建议你选择一个支持依赖管理的构建系统,并且可以使用发布到Maven中心存储库的工件。我们建议你选择Maven或Gradle,可以让Spring Boot与其...

    thursday 评论0 收藏0
  • SpringBoot搭建一个SSM开发框架

    摘要:的子模块我们先讲层,因为我想把配置在这里也说下。长这样我们接下来看看每个子模块如何编写。二子模块搭建子模块搭建子模块配置在将之前,我们先将的配置文件,使用一个全局的配置文件或,我们推荐使用文件。 现在,我们来搭建一个简单的分模块的SSM开发框架吧, 一: 分析并创建项目 先来简单分析下我们项目的结构: 比如:我现在搭建一个管理系统,我们把项目分为: tx-parent 顶级父项目(公...

    tuomao 评论0 收藏0
  • Maven 实战

    摘要:的主要思想是约定优于配置。强烈建议遵循以上规范,避免不必要的麻烦。依赖传递依赖范围除了控制,还会对依赖传递产生影响。此外还提供了和来进一步管理依赖,分别称为可选依赖和排除依赖。 showImg(https://segmentfault.com/img/remote/1460000012363876?w=1240&h=698); Maven 是跨平台的项目管理工具,主要服务于基于Java...

    twohappy 评论0 收藏0

发表评论

0条评论

zzbo

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<