Maven属性插件 [英] Maven Properties Plugin

查看:97
本文介绍了Maven属性插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven Properties插件从属性文件中加载属性.我的项目是一个包含EAR和EJB模块以及相应pom文件的多模块项目.并且有一个父母pom. 如果我没有在所有三个位置都保留属性文件(即在父模块中一个,而在EAR和EJB模块中每个一个),则会出现错误.如果即使在一个位置也没有Properties文件,则抛出FileNotFoundException. 我不想在三个不同的位置保留相同的文件. 请建议我该如何解决.

I am using Maven Properties plugin to load the properties from a properties file. My Project is a multi module project with EAR and EJB modules with there respective pom files. And there is a parent pom. I am getting an error if I dont keep the properties file at all three locations (i.e. one in parent module and one each in EAR and EJB modules). It throws a FileNotFoundException if the Properties file isnt there even in one location. I dont want to keep the same file at three different locations. Please suggest how can I work around with this.

推荐答案

将属性文件放在父项目级别,然后告诉Properties Maven插件从那里引用它.

Put the properties file at the parent project level, then tell the Properties Maven plugin to reference it from there.

  <configuration>
     <files>
        <file>${myPropertyFile}/file>
     </files>
  </configuration>

在父项目中,

   <properties>
      <myPropertyFile>${project.basedir}/foo.properties</myPropertyFile>
   </properties>

在子项目中,

   <properties>
      <myPropertyFile>${project.parent.basedir}/foo.properties</myPropertyFile>
   </properties>

根据您的项目,您也许可以将后者放置为".parent".子项目会继承它.

Depending on your project, you might be able to just put the latter ".parent." version in the parent project and be done with it, since the child projects would inherit it.

这篇关于Maven属性插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆