Maven inherit parent module resources

六眼飞鱼酱① 提交于 2019-12-11 00:08:42

问题


In Maven, is it possible to load resources in a child module from the parent project?

parent project
   ---child module 1
   ---child module 2

I have resources in the parent project src/main/resources which I would like to be made available for the child projects. Ideally the child projects could override any of the resources.


回答1:


Best way to leverage resources from a library and / or override resources that are in the library is to put those resources in the class path. For e.g. say all common configuration are stored in common-config.properties and placed in the src/main/resources of the parent project. If an inheriting project needs to override the configuration, inheriting project can simple place the overridden file under its src/main/resources. In runtime, code should look for this property in classpath and right file will get loaded.



来源:https://stackoverflow.com/questions/33748939/maven-inherit-parent-module-resources

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