在Maven中如何从生成的jar中排除资源? [英] In Maven how to exclude resources from the generated jar?
问题描述
当我创建具有依赖性的可执行jar时(使用本指南),所有属性文件也都打包到该jar中.如何阻止它发生?谢谢.
When I create an executable jar with dependencies (using this guide), all properties files are packaged into that jar too. How to stop it from happening? Thanks.
更新:我尝试使用 Maven排除它们资源插件,但是当我在Eclipse中运行它时,我的应用程序找不到属性文件(右键单击模块->运行方式-> Java应用程序)
UPDATE: I tried to exclude them using the Maven resources plugin, but then my application won't find the properties files when I run it in Eclipse (right click on the module -> Run As -> Java Application)
更新:感谢您的有用回答.我认为我最好花时间学习Maven,因为现在我只选择最简单的解决方案.
UPDATE: Thanks for your useful answers. I think I'd better spend time to learn Maven, for now I just choose the simplest solution.
推荐答案
将这些属性文件放在src/test/resources
中. src/test/resources
中的文件可通过eclipse:eclipse
在Eclipse中自动获得,但Maven不会将其包含在打包的JAR中.
Put those properties files in src/test/resources
. Files in src/test/resources
are available within Eclipse automatically via eclipse:eclipse
but will not be included in the packaged JAR by Maven.
这篇关于在Maven中如何从生成的jar中排除资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!