【问题标题】:No signature of method: static org.springframework.security.oauth.User.withTransaction()没有方法签名:静态 org.springframework.security.oauth.User.withTransaction()
【发布时间】:2011-12-10 02:15:51
【问题描述】:

我有一个问题如下所示;

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)

用户服务:

class UserService {

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

用户.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'
  }
}

我找不到什么问题?

【问题讨论】:

    标签: spring maven groovy spring-security grails-orm


    【解决方案1】:

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

    import org.springframework.security.oauth.User
    

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

    【讨论】:

    • 我改为休眠它现在可以工作了,groovy 真的让我恶心:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-15
    相关资源
    最近更新 更多