使用maven从依赖项目中读取属性文件 [英] read property file from a dependent project with maven

查看:538
本文介绍了使用maven从依赖项目中读取属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个核心项目,我的应用程序依赖于它。



在core的classpath下,它有文件 core.properties



,我的应用程序需要读取此属性文件,但不能。它需要我应用程序的类路径中的 core.properties ,而不是核心。



是否有解决方案那?我的想法中的一个解决方案是,当我构建我的 application.war 时,我可以明确地声明我想要核心依赖关系爆炸吗?



感谢您的帮助!

解决方案

读这个属性文件是什么意思? >

由于它将在类路径上,应该可以使用 getClass()。getResourceAsStream()



如果你真的需要它作为一个文件,你可以使用Dependency插件的 unpack-dependencies 目标来解压缩特定文件,作为构建过程。


I have an issue when reading properties from a dependent project.

I have a core project, and my application has a dependency on it.

under classpath of core, it has file core.properties.

and my application need to read this property file, but it couldn't. It requires the core.properties in my classpath of my application, instead of core.

Is there an solution for that? One solution in my mind is that when I build my application.war, can I explictly declare that I want the core dependency be exploded?

Thanks for help!

解决方案

What do you mean by "read this property file"?

Since it will be on the classpath it should be accessible with getClass().getResourceAsStream().

If you really need it as a file, you can use the Dependency plugin's unpack-dependencies goal to unpack particular files as part of the build process.

这篇关于使用maven从依赖项目中读取属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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