没有方法签名:static org.springframework.security.oauth.User.withTransaction()

时间:2011-10-18 13:04:14

标签: spring maven groovy spring-security gorm

我有一个问题如下所示;

groovy.lang.MissingMethodException: No signature of method:
    static org.springframework.security.oauth.User.withTransaction() is applicable for argument types:
    (org.springframework.security.oauth.services.UserService$_saveUser_closure1) values:
    [org.springframework.security.oauth.services.UserService$_saveUser_closure1@2ed1e8 at 
    groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1357)

UserService:

class UserService {

  public boolean saveUser(){
    boolean retVal=false;
    User.withTransaction{status ->
      def sUser = new User()
      sUser.setUsername("muhammed")
      sUser.save()
      retVal= true
    }
    return retVal;
  }
}

User.groovy:

@Entity
class User {
  String id;
  String username;
  String password;//social agent id

  static constraints = {
    username(nullable:true)
    password(nullable:true)
  }
  static mapping  = {
    id generator: 'uuid'
  }
}

我找不到的问题是什么?

1 个答案:

答案 0 :(得分:1)

我相信您在服务中导入了错误的User类。很可能你有类似

的东西
import org.springframework.security.oauth.User

在您的UserService.groovy文件之上,而您需要导入您的域类。