Grails创建的服务是做什么的?(What does Grails create

编程入门 行业动态 更新时间:2024-10-27 18:23:51
Grails创建的服务是做什么的?(What does Grails create-service do exactly?)

我正在开发一个Grails应用程序(使用Grails 1.3.7)。 在服务层,我没有使用命令'create-service'来创建我的服务,但是手动完成。

结果,我的服务并没有在控制器和其他服务中自动初始化,而且也没有处理事务。

但是我不知道从命令和手动创建服务的区别在哪里? 因为我没有看到任何配置文件找出这个? (我的意思是在传统的Spring中,我们总是有一些配置文件指定应用程序中的所有bean,但在Grails中没有)。

我想解决这个问题并将SVN服务器提交给我的修复程序,但我不想删除旧服务并提交由Grails命令创建的新服务。 所以你可以帮我: 1.解释通过命令创建服务和手动创建服务有什么不同? 2.如何将手动创建的服务更改为通过命令创建的服务而不更换旧服务? 非常感谢!

I am developing a Grails application (with Grails 1.3.7). In service layer, I did not use the command 'create-service' to create my service but do it manually.

As the result, my service was not auto initialize in controllers and other services, and it did not handle transaction.

But I do not know where is the differences from create service by command with by manual? Because I do not see any configuration file which figure out this? (I mean in traditional Spring, we always have some configuration files which specify all beans in applications, but in Grails is not).

I want to fix this issue and commit to SVN server my fix, but I do not want to delete the old service and commit the new one which is created by Grails command. So could you please help me: 1. explain what is the differences from create service by command with by manual? 2. how to change the the service created by manual to service created by command without replacing the old one? Thank you so much!

最满意答案

解释通过命令创建服务和手动创建服务有什么不同?

假设你把你的服务放在grails-app/services并遵循使用Service的后缀的命名约定唯一的区别是你得到一个很好的模板,看起来像

class SomeService { boolean transactional = true def someMethod() { } }

它会自动创建一个名称为SomeServiceTests的单元测试。 这就对了。 BTW交易默认为true如果你不包括它。

如何将手动创建的服务更改为通过命令创建的服务而无需替换旧的?

假设你遵守了惯例,没有什么可以做的。 如果您确实按照惯例行事,并且仍然遇到问题,请更新您的问题,并提供更多详细信息,例如您如何尝试使用您的服务以及您的服务示例。

explain what is the differences from create service by command with by manual?

Assuming you put your service in grails-app/services and followed the naming convention using a postfix of Service The only difference is that you get a nice template that looks like

class SomeService { boolean transactional = true def someMethod() { } }

and it automatically creates a unit test with the name SomeServiceTests. That is it. BTW transactional defaults to true if you do not include it.

how to change the the service created by manual to service created by command without replacing the old one?

There is nothing to do assuming you followed the conventions. If you did follow the conventions and you are still experience problems please update your question with more details such as how are you trying to use your service and a example of your service.

更多推荐

本文发布于:2023-07-04 06:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1019729.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:做什么   Grails   create

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!