pig开发文档

启动网关Failed to instantiate TokenStore

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 
'org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration': Unsatisfied dependency expressed through field 'tokenStore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenStore' defined in class path resource 
[org/springframework/boot/autoconfigure[]curity/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource 
[org/springframework/boot/autoconfigurecurity/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException: 401 null

写在最前边

如果遇到这个问题恭喜你,解决了这个问题 你整个系统差不多都跑起来了!这个问题很常见,十个人有八个是因为配置问题造成

检查数据库配置

pig-auth 端口用户名 之类的好好检查 pig-upms application.yml

好好检查一下,如果没有问题请再看下边的!

解决方法

  1. 检查sys_oauth_client_details配置,有没有修改?
  2. 检查pig-gatway配置,有没有修改?
security:
  validate:
    code: false
  sessions: stateless
  oauth2:
    client:
      client-id: pig
      client-secret: pig
  1. 如果修改,请确保修改值和前端UI保持一致 login.js
export function mobileLogin(mobile, code) {
  var grant_type = 'mobile'
  var scope = 'server'
  return request({
    url: '/auth/mobile/token',
    headers: {
      'Authorization': 'Basic cGlnOnBpZw=='  //此处为 base64(pig:pig)
    },
    method: 'post',
    params: { mobile, code, grant_type, scope }
  })
}
export function login(username, password, randomStr, code) {
  var grant_type = 'password'
  var scope = 'server'
  return request({
    url: '/auth/oauth/token',
    headers: {
      'Authorization': 'Basic cGlnOnBpZw=='  //同上
    },
    method: 'post',
    params: { username, password, randomStr, code, grant_type, scope }
  })
}