在 Maven 标准目录布局中,我应该将规则引擎文件放在哪里?
在 Maven 标准目录布局中,我应该将规则引擎文件放在哪里?具体来说,我正在使用 JBoss Rules (Drools),如果这很重要的话。
In the Maven Standard Directory Layout where do I put Rules Engine files? Specifically, I'm using JBoss Rules (Drools), if that matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我们的项目中,我们只是将它们放在
src/main/resources/
中。它们需要最终出现在类路径上,但不是 Java 代码,因此这似乎是放置它们的明显位置。您还可以创建一个单独的资源目录,例如 src/main/drools/ ,但是您必须在 POM 文件中显式定义它,以便它进入类路径。如果您有许多其他类型的资源已经混乱了
src/main/resources/
,那么单独的目录可能是最好的选择。如果规则文件是您唯一的资源,我会推迟创建一个单独的目录。In our project, we just put them in
src/main/resources/
. They need to end up on the classpath, but aren't Java code, so that seemed like the obvious place to put them.You could also create a separate resource directory like
src/main/drools/
, but then you'd have to define it explicitly in the POM file so that it gets onto the classpath. If you've got lots of other kinds of resources already cluttering upsrc/main/resources/
, then a separate dir is probably the way to go. If the rules files are your only resources, I would hold off on making a separate directory.如果您在构建中未预编译它们(这是默认行为),请将它们放在
src/main/resources/
下。对于构建来说,它们与图像、属性和 xml 文件等其他资源没有什么不同:只需将它们复制到target/classes
即可。但是,如果您正在使用实验性 Maven 插件之一,并且它支持预编译并且您正在预编译它们,那么请将它们放在
src/main/drools/
下,以便构建可以预编译它们并将它们输出到target/classes
。需要理解的是 src/main/java/ 和 src/main/webapp/ 与 src/main/resources/ 不同,因为构建以不同的方式对待每个(在复制期间执行某些操作或复制到不同的位置)。
If you are not precompiling them in your build (this is the default behaviour), put them under
src/main/resources/
. For the build, they are no different from other resources like image, property and xml files: just copy them totarget/classes
.However, if you are using one of the experimental maven plugins and if it supports precompiling and you are precompiling them, then put them under
src/main/drools/
so the build can precompile them and output them totarget/classes
.The thing to understand is that
src/main/java/
andsrc/main/webapp/
are distinct fromsrc/main/resources/
because the build treats each one differently (either doing something during the copy or copying to a different location).