战争构建中缺少包属性文件
我的项目中散布着各种位于包中的属性文件,当包目标从 Maven 构建运行时,这些属性文件不会被包含在内。
使用 0.10.2 m2eclipse 插件和默认的“package”目标。
在项目中:
src->main->java->mypackage->MyProperties.java
src->main->java->mypackage->MyProperties.properties
在运行“package”目标后扩展的 war 目录中:
target->classes->mypackage->MyProperties.class
-- 没有属性文件 --
我试图让小组采用 Maven,解决这个问题将成为一个交易撮合者。移动属性文件是不切实际的。非常感谢任何帮助。
Littered throughout my project are various property files located in packages that are not being included when the package goal is run from a Maven build.
Using the 0.10.2 m2eclipse plugin and the default "package" goal.
In the project:
src->main->java->mypackage->MyProperties.java
src->main->java->mypackage->MyProperties.properties
In expanded war directory after the "package" goal is run:
target->classes->mypackage->MyProperties.class
-- no property file --
I'm trying to get the group to adopt Maven and resolving this issue is going to be a deal maker. Moving the properties files isn't going to be practical. Any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将属性文件放在应用程序/库资源所属的位置,即在 src/main/resources 中:
它将被正确复制。
Put your property files where Application/Library resources belong, i.e. in
src/main/resources
:And it will get copied properly.
Pascal的答案是正确的maven做事方式。
但一些开发人员喜欢将资源放在其来源旁边(例如,这是 wicket 中的标准程序)。
如果您打算这样做,则必须将源文件夹添加到资源中:
Pascal's answer is the correct maven way of doing things.
But some developers like to keep resources next to their sources (it's standard procedure in wicket, for example).
If you're going to do that, you will have to add your source folder to the resources:
我帮助检查构建路径。资源的属性被排除在外。当我再次包含它们时,战争从资源中获取了所有属性文件,并且 tomcat 部署正确。
Me helped to check build path. The rpoperties of resources were excluded. When I included them again, the war got all property-files from resource and tomcat deployed correct.
我有同样的问题。解决方案是检查 Eclipse 中项目的构建路径。在“源”中查找“yourProject/src/main/resources”。节点“排除:**”在这里删除过滤器,应用并使用 Maven 再次构建。然后再次启用过滤器并像所有属性文件一样运行。
希望这有帮助
I had same problem. Solution was check Build Path of project at Eclipse. At "source" look for "yourProject/src/main/resources". The node "Excluded: **" here you remove the filter, apply and build again with Maven. Then enable the filter again and runs like a charme with all property-files.
Hope this helps