【问题标题】:grails-app/utils dirgrails-app/utils 目录
【发布时间】:2011-01-13 16:37:17
【问题描述】:

我刚刚注意到grails-app/utils 目录的存在。我从未在任何文档中看到过它(或在项目中使用过)。它是在您运行 create-app 时默认创建的,您知道您应该在其中放入什么吗?

“实用程序”代码是一个明显的猜测,但它似乎应该放在 src 目录下。

谢谢, 唐

【问题讨论】:

    标签: grails


    【解决方案1】:

    grails-app/utils/ 目录是 Codecs 等项目所在的位置。

    我不确定那里还有什么,但您可以在其中包含其他类,它们将包含在应用程序中

    编辑: grails-app/utils/ 目录用于“Grails 特定实用程序”(ArtefactsGrailsClasses 等)

    Jeff Brown(Core member of the Grails development team) 回复了question on the mailing list,证实了这一点。他说:

    你可以放任何你喜欢的东西 就像在utils 目录中一样,但它是 真的适用于 Grails 特定的实用程序。 目前我认为唯一的 真正针对这个目录的是 自定义编解码器。你的申请 不是 Grails 工件的类 应该去src/groovy/

    您可以在Constriants plugin 中找到新的 Grails Artefact 示例。本插件作者推荐用户put their Constraint classes in the grails-app/utils/ directory

    【讨论】:

    • 此信息对于 grails 2 是正确的。在 grails 3.0 中,实用程序类位于 src/main/groovy/ 下。我想这可能有助于人们在 2015 年搜索“grails ulity classes”。
    • 如果 util 文件夹不存在,请告诉我如何创建它。通过右键单击“项目-> 新建-> 文件夹”只需创建一个普通文件夹。但在另一个项目中,我看到有人创建了它,它有一个剪刀标志。这是图片链接:drive.google.com/file/d/0BxcLSUsfZQKHemZUR3dGSEM0WVk/…
    • @KamaldeepSingh Grails Projects 2.x 有默认创建的 utils 目录。 Grails 3.x 没有,如果你手动创建它,它将是一个公共目录而不是标准。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多