Grails Packaging and Naming Conventions

六月ゝ 毕业季﹏ 提交于 2019-12-23 18:43:49

问题


Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services

Is this a good practice or should be avoided by all means??

Another worth mentioning problem I encountered is in naming services Example

SomthingGatewayService.groovy can't be initialized in both these ways - SomthingGatewayService somtinggatewayService
- def somtinggatewayService I understand that the problem is in the 2 Capital Letters 'S'omthing and 'G'ateway before the conventional 'S'ervice, so its probably because of some sort of spring DI issue

So how to resolve this?


回答1:


Yes, putting Domain classes, services, controllers etc. into packages is a good idea IMO. Refactoring it later can be painful. Especially when dealing big applications or applications that grow over time.

Regarding the second problem: If you have a service called SomthingGatewayService then you'll be able to reference it by def somthingGatewayService (just the first letter is lower case).



来源:https://stackoverflow.com/questions/1721630/grails-packaging-and-naming-conventions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!