【发布时间】:2019-06-10 13:09:47
【问题描述】:
好的,我有一个多模块项目,在一个插件中包含服务,以及多个使用它的网络“应用程序”。
用户和播放器服务有一个登录和注册方法,需要通过更新会话来“登录”播放器。
此帖:Grails get Session and Management in Service class
有一些解决方案,但似乎没有一个真正有效。 Webutils 在这些位置均不可用
import org.codehaus.groovy.grails.web.util.WebUtils
import org.grails.web.util.WebUtil
import org.grails.web.util.WebUtils
这也不起作用:
def session = getSession(true)
有什么建议吗?
这是来自插件的 build.gradle:
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.5.Final"
compile "org.grails.plugins:scaffolding"
console "org.grails:grails-console"
profile "org.grails.profiles:plugin"
provided "org.grails:grails-plugin-services"
provided "org.grails:grails-plugin-domain-class"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails:grails-plugin-testing"
}
【问题讨论】:
-
“Webutils 在这些位置都不可用” - 但是,在 Grails 3.3.9
WebUtils does exist atorg.grails.web.util.WebUtils 中,您不应该使用它。请参阅下面的答案。