Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
spring安全核心grails中的错误_Spring_Grails - Fatal编程技术网

spring安全核心grails中的错误

spring安全核心grails中的错误,spring,grails,Spring,Grails,我使用的是GrailsSpringSeurity内核,这是一个非常新的版本。我得到以下错误 Configuring Spring Security Core 1.2.7.3... ... finished configuring Spring Security Core **| Error 2014-01-10 09:40:36,688 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing

我使用的是GrailsSpringSeurity内核,这是一个非常新的版本。我得到以下错误

Configuring Spring Security Core 1.2.7.3...
... finished configuring Spring Security Core

**| Error 2014-01-10 09:40:36,688 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Assertion failed: 

assert SecUserSecRole.count() == 1
                      |       |
                      0       false

Message: Assertion failed: 

assert SecUserSecRole.count() == 1
                      |       |
                      0       false**

   Line | Method
引导类如下所示

class **BootStrap** {

    def springSecurityService
    def init = { servletContext ->

        //def userRole= SecRole.findByAuthority("ROLE_USER") ?: new SecRole(authority : "ROLE_USER").save()
        //def adminRole= SecRole.findByAuthority("ROLE_ADMIN") ?: new SecRole(authority : "ROLE_ADMIN").save()
        def adminRole = new SecRole(authority: 'ROLE_ADMIN').save(flush: true)
        def userRole = new SecRole(authority: 'ROLE_USER').save(flush: true)

        //  def testUser = new SecUser(username: username, enabled: true, password: springSecurityService.encodePassword("password"))
        /// testUser.save(flush: true)

        //SecUserSecRole.create testUser, adminRole, true
        def testUser = new SecUser(username: 'admin', enabled: true, password: 'admin')
        testUser.save(flush: true)

        SecUserSecRole.create testUser, adminRole, true

        assert SecUser.count() == 1
        assert SecRole.count() == 2
        assert SecUserSecRole.count() == 1
    }
    def *destroy* = {
    }
}

您需要在BootStrap.groovy中显示创建用户和角色的代码。请显示您的
SecUserSecRole.create
code静态SecUserSecRole创建(SecUser-SecUser,SecRole-SecRole,boolean flush=false){new SecUserSecRole(SecUser:SecUser,SecRole:SecRole)。保存(flush:flush,insert:true)}您应该在问题中发布该代码。我所做的观察(Grails 2.1.1)是,引导程序在所有测试之后运行(至少对我来说…)。我通常在“public void setup()”方法中创建我的设置。