【问题标题】:Importing services in the Grails console?在 Grails 控制台中导入服务?
【发布时间】:2012-09-25 20:43:34
【问题描述】:

如何在 grails 控制台中获取服务?我的业务规则在服务中实现,但我无法在 grails 控制台中访问它们。有谁知道如何帮助我?

【问题讨论】:

  • 你是指运行grails console时得到的图形Groovy控制台吗?

标签: grails grails-web-console


【解决方案1】:

Spring ApplicationContext 在控制台中作为ctx 变量可用,您可以使用它来访问Spring bean,例如服务。通常是 def myService = ctx.getBean('myService'),但 Grails 添加了一个元类助手,所以你可以只做 def myService = ctx.myService

【讨论】:

  • 伯特贝克威斯感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-04
相关资源
最近更新 更多