Grails会话范围的服务 - 不起作用 [英] Grails session-scoped service - not working

查看:98
本文介绍了Grails会话范围的服务 - 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中一个Grails服务(Grails 2.2.2)中添加了 static scope =session,但由于某种原因,它的行为类似于单例。

你能否将会话服务注入到单例(默认)服务中?

换句话说,有什么理由不应该这样做?

  class DefaultService {
def sessionService
}

class SessionService {
static scope ='session'

def instanceVar = ...
}

我该如何解决为什么这不起作用?

解决方案

我希望这个帮助你。



简而言之,你不能在单身人士中使用会话范围的服务,标签库。手动使用服务代理,或作用域代理插件


I added static scope = "session" in one of my Grails services (Grails 2.2.2), but for some reason it is behaving like a singleton.

Can you not inject session services into singleton (default) services?

In other words, is there any reason why this shouldn't work?

class DefaultService {
  def sessionService
}

class SessionService {
  static scope = 'session'

  def instanceVar = ...
}

How would I troubleshoot why this isn't working?

解决方案

I hope this help you.

In short, you can not use session scoped services in singletons, like usual services or taglibs. Use service proxy by manually, or Scoped Proxy Plugin.

这篇关于Grails会话范围的服务 - 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆