简体   繁体   English

Maven,从jar中排除资源,然后在战争中添加它们

[英]Maven, exclude resources from jar and add them in resulting war

I have a multi-module maven project like the following 我有一个如下的多模块Maven项目

<modules>
  <module>mod1</module>
  <module>jarMod</module>
  <module>warMod</module>
</modules>

In the end, everything is assembled in warMod war archive through maven dependencies and war packaging. 最后,所有内容都通过maven依赖关系和war包装在warMod war归档中进行了组装。 In jarMod I have property files under /resources, which I want to exclude from jar and have them in resulting war (so when app is deployed, I can modify those files). 在jarMod中,我在/ resources下有属性文件,我想从jar中排除这些属性文件,并使它们引起战争(因此,在部署应用程序时,我可以修改这些文件)。

I've managed to exclude files from jar, as for now, and add path to them to class-path in jar manifest. 到目前为止,我设法从jar中排除了文件,并将它们的路径添加到jar清单中的类路径中。 Remaining problem is, how do I add them in resulting war file (like in WEB-INF) and still access them from classes in jar? 剩下的问题是,如何将它们添加到生成的war文件中(例如在WEB-INF中),并且仍然从jar中的类访问它们? Right now it's done through 'getResourceAsStream()' 现在,它是通过“ getResourceAsStream()”完成的

进行战争时,您可以将属性文件复制到WEB-INF / classes下,以将其放置在类路径中(就像它在jar中一样)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM