Spring cloud oauth2 研究第N天

抱歉,原先没有发表,是因为一直在参考 

http://blog.csdn.net/j754379117/article/details/70176974

http://blog.csdn.net/j754379117/article/details/70175198

https://spring.io/guides/tutorials/spring-boot-oauth2/


现在配置好,运行报

PreparedStatementCallback; bad SQL grammar [select username,password,enabled from users where username = ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'users' doesn't exist


不难看出在Spring Security源码中导数据库中查询用户名密码,及其用户对应的权限是其固定写在代码里面的,这就是为什么网上的一些小的demo中数据库为什么这么创建的原因。下面给出MySQL创建这两张的SQL语句及其插入数据的相关语句:

Sql代码    收藏代码
  1. create table users(  
  2. username varchar(50) not null primary key,  
  3. password varchar(50) not null,  
  4. enabled boolean not null  
  5. );  
  6. create table authorities (  
  7. username varchar(50) not null,  
  8. authority varchar(50) not null,  
  9. constraint fk_authorities_users foreign key(username) references users(username)  
  10. );  
  11. create unique index ix_auth_username on authorities (username,authority);  
  12.   
  13. insert into users(username,password,enabled) values('admin','admin',true);  
  14. insert into users(username,password,enabled) values('user','user',true);  
  15.   
  16. insert into authorities(username,authority) values('admin','ROLE_ADMIN');  
  17. insert into authorities(username,authority) values('admin','ROLE_USER');  
  18. insert into authorities(username,authority) values('user','ROLE_USER'); 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值