java 代码读取pom,Maven:如何读取父POM版本

本文讨论了在Java项目中如何避免复制粘贴重复的配置信息,通过创建一个父POM来解决这个问题。作者指出,当父POM和配置文件模块需要一起部署时,依赖版本匹配成为问题。在应用中使用父POM时,${project.version}被解析为应用版本而非父POM版本,导致找不到配置文件。解决方案是在父POM中使用${project.parent.version}或者通过pluginManagement和dependencyManagement来管理版本和配置。
摘要由CSDN通过智能技术生成

Background: Most of my Java project have a lot of boiler-plate configuration that I end up writing into my POM. (For example the sourceEncoding is always UTF-8, the organization details never change). To save having to copy-paste blocks of configuration I've created my own standard 'parent' POM I can extend for each of my projects.

I also have a number of tools that I use in every Java project I work on (e.g. checkstyle, PMD etc) so I've added the plug-ins for each tool into my standard parent pom.

PMD (and a few other tools) have an interesting problem - they requires a set of configuration files to operate correctly. Since Maven prefers to work with the concept of 'one deployable resource per module' I've created the following (simplified) structure:

|--- Config Files

\--- Parent Pom

My Template: is a maven controlled project with t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值