Maven Properties Plugin

☆樱花仙子☆ 提交于 2019-12-13 05:14:16

问题


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.


回答1:


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>

In the parent project,

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

In the child projects,

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

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.




回答2:


In a production ready application you wouldn't want your properties to be bundled in your app, but rather be outside of it, so you can change just them rather than having to rebuild the whole app, so I would advise you to make your application production-ready and not have the properties included in the first place.



来源:https://stackoverflow.com/questions/21020755/maven-properties-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!