在多模块maven项目中指定公共资源 [英] Specify common resources in a multi-module maven project

查看:100
本文介绍了在多模块maven项目中指定公共资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Maven的父项目模块之间共享资源?例如,我想为多模块Maven项目中的所有模块指定一个log4j.properties文件。

Is there any way to share resources between modules of a parent project in Maven? For example, I would like to specify one log4j.properties file for all the modules in a multi-module Maven project.

通常,我使用Eclipse IDE创建父模块通过选择一般项目然后通过指定 pom 的包装将其转换为Maven项目来进行项目。这创建了一个干净的项目结构,没有 src 等文件夹。我想知道在这种情况下应该放置这样的共享资源。

Generally, I use Eclipse IDE to create the parent project by choosing a general project and then convert it to a Maven project by specifying a packaging of pom. This creates a "clean" project structure without src and etc. folders. I wonder where such a shared resource should be put in this case.

EDIT1 :我想将公共资源放在父项目中。

EDIT1: I would like to put the common resources in the parent project.

推荐答案

我创建了一个额外的基础模块(项目),打包jar,其中包含公共资源在 src / main / resources 中。然后我会让其他模块依赖于该项目。现在他们看到了类路径上的公共资源。

I'd create one additional "base" module (project), packaging "jar", that contains the common resources in src/main/resources. Then I'd make the other modules depend on that project. Now they see the common resources on their classpaths.

这篇关于在多模块maven项目中指定公共资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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