我正在使用 java spring boot 进行休息服务。这些表在数据库中正确创建,并在本地测试一切正常,但是当我在我的 vps 中的 tomcat 中安装 .war 时,失败开始。
对/oatuh/ token 执行 POST 请求来登录会引发异常:
"could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet"
用户实体:
@Entity
@Table(name = "users")
public class UserEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7125479784396028079L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Long id;
@Column(name = "username", unique = true)
private String username;
@Column(name = "password")
private String password;
@Column(name = "email", unique = true)
private String email;
DAO:
@Repository
public interface UserDao extends JpaRepository<UserEntity, Long>{
@Query("select u from UserEntity u where u.username = ?1")
public UserEntity findByUsername(String username);
}
服务:
@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserEntity user = userDao.findByUsername(username);
System.out.println(user);
if (user == null) {
log.error("El usuario no existe en la base de datos.");
throw new UsernameNotFoundException("Usuario inexistente en la base de datos");
}
return new User(user.getUsername(), user.getPassword(), true, true, true, true, null);
}
最佳答案
@Column(name = "lastModifiedBy")
private int lastModifiedBy;
@Column(name = "lastModifedOn")
private Date lastModifiedOn;
我的代码 lastModifedOn
中存在拼写错误,我将其更改为 lastModifiedOn
,问题已永久修复。
关于java - 无法提取结果集; SQL [不适用];嵌套异常是 org.hibernate.exception.SQLGrammarException : could not extract ResultSet with oauth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60941802/