Grails java.lang.IllegalStateException:没有绑定到线程的数据存储会话,并且配置不允许在此创建非事务会话

Grails java.lang.IllegalStateException:没有绑定到线程的数据存储会话,并且配置不允许在此创建非事务会话,grails,Grails,我在本地运行grails应用程序时遇到以下错误 file:/home/schepuri/grails/2.4.4/projects/my-app/plugins/excel-import-0.9.6/lib/xmlbeans-2.3.0-without-w3c.jar ------------------------------------------------------------- java.lang.IllegalStateException: No Datastore Session

我在本地运行grails应用程序时遇到以下错误

file:/home/schepuri/grails/2.4.4/projects/my-app/plugins/excel-import-0.9.6/lib/xmlbeans-2.3.0-without-w3c.jar
-------------------------------------------------------------
java.lang.IllegalStateException: No Datastore Session bound to thread, and configuration does not allow creation of non-transactional one here
        at org.grails.datastore.mapping.core.DatastoreUtils.doGetSession(DatastoreUtils.java:149)
        at org.grails.datastore.mapping.core.AbstractDatastore.getCurrentSession(AbstractDatastore.java:141)
        at org.grails.datastore.gorm.GormStaticApi.createCriteria(GormStaticApi.groovy:297)
这是我的BuildConfig.groovy文件

 dependencies {
compile 'org.grails:grails-datastore-gorm-plugin-support:3.1.3.RELEASE'
    compile 'org.grails:grails-datastore-gorm:3.1.3.RELEASE'
    compile 'org.grails:grails-datastore-core:3.1.3.RELEASE'
}

plugins {
  compile (":mongodb:3.0.2") {
    excludes 'grails-datastore-gorm-plugin-support'
    excludes 'grails-datastore-gorm'
    excludes 'grails-datastore-core'
  }
}

我是否在buildconfig文件或发生此异常的

中缺少任何依赖插件?请出示你的密码。似乎您试图在运行内部调用服务类脚本的groovy脚本时使用作用域之外的数据库?什么剧本?您好@IgorArtamonov,基本上我已经在“MyProj/scripts”文件夹中创建了一个grails脚本,它在内部调用我项目的服务类方法。因此,当我运行该脚本时,它抛出了上述错误。例如:我创建了LoadUser.groovy脚本,它在内部调用LoadUserService.groovy类。所以现在当我运行LoadUser脚本时,它抛出了上面的错误。你可以尝试
YouDomain.withTransaction{}
当然,可能会以某种黑客的方式工作,但我不认为这个目录中的脚本应该以这种方式使用。它用于定制构建过程,而不是像数据库这样的应用程序状态,在哪里发生此异常?请出示你的密码。似乎您试图在运行内部调用服务类脚本的groovy脚本时使用作用域之外的数据库?什么剧本?您好@IgorArtamonov,基本上我已经在“MyProj/scripts”文件夹中创建了一个grails脚本,它在内部调用我项目的服务类方法。因此,当我运行该脚本时,它抛出了上述错误。例如:我创建了LoadUser.groovy脚本,它在内部调用LoadUserService.groovy类。所以现在当我运行LoadUser脚本时,它抛出了上面的错误。你可以尝试
YouDomain.withTransaction{}
当然,可能会以某种黑客的方式工作,但我不认为这个目录中的脚本应该以这种方式使用。它用于定制构建过程,而不是像数据库那样的应用程序状态