Spring 启动 oauth2 令牌

Spring boot oauth2 token

我有一个 ouath2 模块,服务器 运行 在端口 9999 上,当我请求 "localhost:9999/oauth/token" 时,我确实得到了令牌。 然而,即使 auth 服务器和 REST 端点在同一个项目中(不同的模块,但它们相互了解),控制器似乎并不关心请求是否持有令牌。

现在,有趣的东西来了:

如果我将此代码添加到我的 application.yml,控制器根本不关心身份验证。

security:
  basic:
    enabled: false
  oauth2:
    client:
      client-id: acme
      client-secret: acmesecret
      access-token-uri: http://localhost:9999/oauth/token
      user-authorization-uri: http://localhost:9999/oauth/authorize
    resource:
      user-info-uri: http://localhost:9999/user
      token-info-uri: http://localhost:9999/oauth/check_token

auth:
 server:
  url: http://localhost:9999/oauth/check_token/
  clientId: acme
  clientSecret: acmesecret
oauth2:
 resource:
  userInfoUri: http://localhost:9999/user

但是,当我删除它并尝试请求控制器时,我得到了这个:

{
  "timestamp": 1472114046044,
  "status": 401,
  "error": "Unauthorized",
  "message": "Full authentication is required to access this resource",
  "path": "/gamification/api/ebubo"
}

有什么想法吗?有人吗?

@ComponentScan("the_actual_package") 丢失