Grails session-scoped service - not working

与世无争的帅哥 提交于 2020-01-15 22:27:47

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/18724567/grails-session-scoped-service-not-working

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