【发布时间】:2018-02-07 18:04:06
【问题描述】:
我正在开发一个使用 Oauth2 并连接 SqlServer 的 spring-boot 应用程序。因此,当我点击如下所示的访问令牌 URL 时:
localhost:8081/oauth/token?client_secret=secret&client_id=web&grant_type=password&username=XXXX&password=XXXXXXX
我得到的回应是:
{
"error": "invalid_grant",
"error_description": "Bad credentials"
}
所以我觉得这是因为@Table 注释和hibernate 的命名约定错误。我/我正在使用spring 1.5.9 and hibernate 5.0.12。
我的 Account.java 文件是:
package com.oauth.oserver.entities;
import javax.persistence.*;
@Entity
@Table(name = "userinfo")
public class Account {
@Id
@GeneratedValue
private Long id;
@Column(name = "name")
private String username;
@Column(name = "password")
private String password;
public Account() {
}
public Account(String username, String password) {
this.username = username;
this.password = password;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
数据库包含名称为UserInfo的表。
【问题讨论】:
-
您可以在这里发布您的控制器和服务吗?
标签: sql-server spring hibernate spring-boot naming-conventions