Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.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
Grails Spring Security插件不';I don’我不能和一个以上的人一起工作。为什么?_Grails_Groovy_Spring Security_Grails Plugin - Fatal编程技术网

Grails Spring Security插件不';I don’我不能和一个以上的人一起工作。为什么?

Grails Spring Security插件不';I don’我不能和一个以上的人一起工作。为什么?,grails,groovy,spring-security,grails-plugin,Grails,Groovy,Spring Security,Grails Plugin,我有一门课是这样的: class User { String name; String password; static hasMany = [ authorities : testing.Role ] static belongsTo = Role static constraints = { name(unique:true,size:4..10) } } static belongsTo = [ Role , company

我有一门课是这样的:

class User {
    String name;
    String password;    
    static hasMany = [ authorities : testing.Role ]
    static belongsTo = Role
    static constraints = {
    name(unique:true,size:4..10)
    }
}
static belongsTo = [ Role , company : Company]
/home/anto/anto/test/testing/grails-app/domain/testing/User.groovy: 7: Unexpected node type: EXPR found when expecting type: LABELED_ARG at line: 7 column: 25. File: /home/anto/anto/test/testing/grails-app/domain/testing/User.groovy @ line 7, column 25.
       static belongsTo = [Role , company : Company ] 
                           ^

1 error
static belongsTo = Role
我已经配置了Spring安全插件(acegi)并按预期工作。但问题是,当我将
用户
类中的
属性更改为以下内容时:

class User {
    String name;
    String password;    
    static hasMany = [ authorities : testing.Role ]
    static belongsTo = Role
    static constraints = {
    name(unique:true,size:4..10)
    }
}
static belongsTo = [ Role , company : Company]
/home/anto/anto/test/testing/grails-app/domain/testing/User.groovy: 7: Unexpected node type: EXPR found when expecting type: LABELED_ARG at line: 7 column: 25. File: /home/anto/anto/test/testing/grails-app/domain/testing/User.groovy @ line 7, column 25.
       static belongsTo = [Role , company : Company ] 
                           ^

1 error
static belongsTo = Role
我试着运行
grails run app
我得到如下错误:

class User {
    String name;
    String password;    
    static hasMany = [ authorities : testing.Role ]
    static belongsTo = Role
    static constraints = {
    name(unique:true,size:4..10)
    }
}
static belongsTo = [ Role , company : Company]
/home/anto/anto/test/testing/grails-app/domain/testing/User.groovy: 7: Unexpected node type: EXPR found when expecting type: LABELED_ARG at line: 7 column: 25. File: /home/anto/anto/test/testing/grails-app/domain/testing/User.groovy @ line 7, column 25.
       static belongsTo = [Role , company : Company ] 
                           ^

1 error
static belongsTo = Role
为什么这个语法会抛出错误?我在哪里犯了错误

编辑: 现在,在从少数人那里得到答案后,我将代码更改为:

static belongsTo = [ role: Role , company : Company]
但这次我犯了更大的错误

2011-12-31 14:23:57,304 [Thread-9] ERROR context.ContextLoader  - Context initialization failed 
Message: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: No owner defined between domain classes [class testing.Role] and [class testing.User] in a many-to-many relationship. Example: static belongsTo = testing.User 
   Line | Method 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask 
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker 
|   908 | run      in     '' 
^   662 | run . .  in java.lang.Thread 

Caused by GrailsDomainException: No owner defined between domain classes [class testing.Role] and [class testing.User] in a many-to-many relationship. Example: static belongsTo = testing.User 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask 
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker 
|   908 | run      in     '' 
^   662 | run . .  in java.lang.Thread 
| Error 2011-12-31 14:23:57,401 [Thread-9] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: No owner defined between domain classes [class testing.Role] and [class testing.User] in a many-to-many relationship. Example: static belongsTo = testing.User 
Message: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: No owner defined between domain classes [class testing.Role] and [class testing.User] in a many-to-many relationship. Example: static belongsTo = testing.User 
   Line | Method 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask 
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker 
|   908 | run      in     '' 
^   662 | run . .  in java.lang.Thread 

Caused by GrailsDomainException: No owner defined between domain classes [class testing.Role] and [class testing.User] in a many-to-many relationship. Example: static belongsTo = testing.User 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask 
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker 
|   908 | run      in     '' 
^   662 | run . .  in java.lang.Thread
现在,发生了什么事

但如果我这样做:

class User {
    String name;
    String password;    
    static hasMany = [ authorities : testing.Role ]
    static belongsTo = Role
    static constraints = {
    name(unique:true,size:4..10)
    }
}
static belongsTo = [ Role , company : Company]
/home/anto/anto/test/testing/grails-app/domain/testing/User.groovy: 7: Unexpected node type: EXPR found when expecting type: LABELED_ARG at line: 7 column: 25. File: /home/anto/anto/test/testing/grails-app/domain/testing/User.groovy @ line 7, column 25.
       static belongsTo = [Role , company : Company ] 
                           ^

1 error
static belongsTo = Role
一切正常。我不知道为什么前面的语法会抛出这样的错误

我是Grails的初学者,需要帮助

注: 我正在使用Grails2.0


提前感谢。

应该是
static belongsTo=[role:role,company:company]

应该是
static belongsTo=[role:role,company:company]

这根本不是安全问题,而是GORM问题
[Role,company:company]
毫无意义,因为您将Groovy的列表语法(
[Foo,Bar,Baz]
)与其映射语法(
[Foo:Foo,Bar:Bar,Baz:Baz]
)混为一谈。您必须选择一个。

这根本不是安全问题,而是GORM问题
[Role,company:company]
毫无意义,因为您将Groovy的列表语法(
[Foo,Bar,Baz]
)与其映射语法(
[Foo:Foo,Bar:Bar,Baz:Baz]
)混为一谈。您必须选择一个。

堆栈跟踪似乎表明问题在关系的另一边。角色和公司类看起来如何?它们都应该有一个类似“User User”的属性。

stacktrace似乎表明问题出在关系的另一边。角色和公司类看起来如何?它们都应该有一个类似于“User-User”的属性。

Ant您应该阅读stacktrace并在文档中搜索解决方案。您是初学者,但首先自己搜索,然后向StackOverflow寻求帮助。这就是原因:
在多对多关系中的域类[class testing.Role]和[class testing.User]之间没有定义所有者。示例:static belongsTo=testing.User
,您应该在这里寻找解决方案:@TomaszKalkosiński:我知道这就是问题所在。但是我想知道,如果这个方法有效,为什么这个方法无效并抛出错误呢!!。这是我的疑问。Ant的建议您应该阅读stacktrace并在文档中搜索解决方案。您是初学者,但首先自己搜索,然后向StackOverflow寻求帮助。这就是原因:
在多对多关系中的域类[class testing.Role]和[class testing.User]之间没有定义所有者。示例:static belongsTo=testing.User
,您应该在这里寻找解决方案:@TomaszKalkosiński:我知道这就是问题所在。但是我想知道,如果这个方法有效,为什么这个方法无效并抛出错误呢!!。这是我的疑问。