没有方法签名:static org.springframework.security.oauth.User.withTransaction()
我有一个问题如下所示;
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'
}
}
我找不到什么问题?
i have a problem is shown below;
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'
}
}
what is the problem i cant find?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您在服务中导入了错误的 User 类。 有类似的内容,而您需要导入域类。
最有可能的是,您的 UserService.groovy 文件顶部
I believe you imported the wrong User class in your service. Most likely you have something like
on top of your UserService.groovy file, whereas you need to import your domain class.