【问题标题】:Grails Packaging and Naming ConventionsGrails 打包和命名约定
【发布时间】:2010-12-15 20:25:21
【问题描述】:

包装控制器、服务等。 IE。 - com.company.controllers - com.company.services

这是一种好的做法还是应该尽一切办法避免?

我遇到的另一个值得一提的问题是在命名服务示例中

SomthingGatewayService.groovy 无法通过这两种方式初始化 - SomthingGatewayService somtinggatewayService
- def somtinggatewayService 我知道问题出在传统“服务”之前的 2 个大写字母 'S'omthing 和 'G'ateway 中,因此可能是由于某种 spring DI 问题

那么如何解决呢?

【问题讨论】:

    标签: web-services spring grails dependency-injection


    【解决方案1】:

    是的,将域类、服务、控制器等放入包中是 IMO 的一个好主意。稍后重构它可能会很痛苦。尤其是在处理大型应用程序或随时间增长的应用程序时。

    关于第二个问题:如果您有一个名为SomthingGatewayService 的服务,那么您可以通过def somthingGatewayService 引用它(只是第一个字母是小写的)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-29
      • 1970-01-01
      • 2013-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-13
      相关资源
      最近更新 更多