我遇到了完全相同的问题。请检查以确保在BootStrap.groovy中创建用户时,您首先使用密码和所有字段创建用户,即使它们是可选的(不知道为什么)。然后创建新的角色,然后将该角色添加到该角色。
检查用户是否分配给角色的一种方法是查看将用户映射到角色的role_people表。
这是我BootStrap.groovy中的文件:
class BootStrap {
// include this line to encode password for ACEGI
def authenticateService
def init = { servletContext ->
//create admin user
def password = authenticateService.passwordEncoder("password")
def superadmin = new User(username:"admin",userRealName:"Administrator",passwd:password,enabled:true,emailShow:true,description:"admin user",email:"put email here").save()
//create admin role
def sudo = new Role(authority:"ROLE_ADMIN",description:"Site Administrator")
// now add the User to the role
sudo.addToPeople(superadmin)
sudo.save()
new Role(authority:"ROLE_USER",description:"User").save()
}
def destroy = {
}
}
我发现我的问题。我必须自己编辑/编码passwordEncoder()或encodePassword()方法(使用我的算法等)。 passwordEncoder()已弃用,请使用encodePassword()! – whitenexx 2009-05-03 21:37:32