异常信息为

2021-08-22 14:24:11.086 WARN 17812 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authController': Unsatisfied dependency expressed through field 'tokenEndpoint'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.oauth2.provider.endpoint.TokenEndpoint' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2021-08-22 14:24:11.107 INFO 17812 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-08-22 14:24:11.184 WARN 17812 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.client.listener] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@14/jdk.internal.misc.Unsafe.park(Native Method)
java.base@14/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
java.base@14/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
java.base@14/java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:460)
app//com.alibaba.nacos.client.naming.core.EventDispatcher$Notifier.run(EventDispatcher.java:118)
java.base@14/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base@14/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base@14/java.lang.Thread.run(Thread.java:832)
2021-08-22 14:24:11.185 WARN 17812 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.client.naming.updater] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@14/jdk.internal.misc.Unsafe.park(Native Method)
java.base@14/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
java.base@14/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@14/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
java.base@14/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
java.base@14/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base@14/java.lang.Thread.run(Thread.java:832)
2021-08-22 14:24:11.186 WARN 17812 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.client.naming.updater] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@14/jdk.internal.misc.Unsafe.park(Native Method)
java.base@14/java.util.concurrent.locks.LockSupport.park(LockSupport.java:341)
java.base@14/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:505)
java.base@14/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3137)
java.base@14/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1614)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1177)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@14/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
java.base@14/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
java.base@14/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base@14/java.lang.Thread.run(Thread.java:832)
2021-08-22 14:24:11.187 WARN 17812 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.failover] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@14/jdk.internal.misc.Unsafe.park(Native Method)
java.base@14/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
java.base@14/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
java.base@14/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
java.base@14/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
java.base@14/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base@14/java.lang.Thread.run(Thread.java:832)
2021-08-22 14:24:11.187 WARN 17812 --- [ main] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [com.alibaba.nacos.naming.push.receiver] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@14/java.net.DualStackPlainDatagramSocketImpl.socketReceiveOrPeekData(Native Method)
java.base@14/java.net.DualStackPlainDatagramSocketImpl.receive0(DualStackPlainDatagramSocketImpl.java:130)
java.base@14/java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:181)
java.base@14/java.net.DatagramSocket.receive(DatagramSocket.java:864)
app//com.alibaba.nacos.client.naming.core.PushReceiver.run(PushReceiver.java:73)
java.base@14/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
java.base@14/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
java.base@14/java.util.concurrent.FutureTask.run(FutureTask.java)
java.base@14/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
java.base@14/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base@14/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base@14/java.lang.Thread.run(Thread.java:832)
2021-08-22 14:24:11.203 INFO 17812 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-08-22 14:24:11.501 ERROR 17812 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field tokenEndpoint in com.nebula.cloud.auth.controller.AuthController required a bean of type 'org.springframework.security.oauth2.provider.endpoint.TokenEndpoint' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'org.springframework.security.oauth2.provider.endpoint.TokenEndpoint' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:56396', transport: 'socket'

Process finished with exit code 1

自定义实现认证授权服务,报以上异常错误

异常内容报错很明显是TokenEndpoint这个对象并没有实例化,注入失败

但是为什么会是实例化失败呢

spring boot在启动时候回自动注入相关依赖,实例化TokenEndpoint,然而事实上并没有,经过分析是未在配置类上添加@EnableAuthorizationServer导致

EnableAuthorizationServer这个注解上会导入

AuthorizationServerEndpointsConfiguration

如果为配置@EnableAuthorizationServer这个注解,就不会实例化TokenEndpoint对象

												

spring-security-oauth2使用遇到的坑的更多相关文章

  1. Spring Boot 中使用 Spring Security, OAuth2 跨域问题 (自己挖的坑)

    使用 Spring Boot 开发 API 使用 Spring Security + OAuth2 + JWT 鉴权,已经在 Controller 配置允许跨域: @RestController @C ...

  2. Spring Security OAuth2学习

    什么是 oAuth oAuth 协议为用户资源的授权提供了一个安全的.开放而又简易的标准.与以往的授权方式不同之处是 oAuth 的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需 ...

  3. 【OAuth2.0】Spring Security OAuth2.0篇之初识

    不吐不快 因为项目需求开始接触OAuth2.0授权协议.断断续续接触了有两周左右的时间.不得不吐槽的,依然是自己的学习习惯问题,总是着急想了解一切,习惯性地钻牛角尖去理解小的细节,而不是从宏观上去掌握 ...

  4. 使用Spring Security Oauth2完成RESTful服务password认证的过程

            摘要:Spring Security与Oauth2整合步骤中详细描述了使用过程,但它对于入门者有些重量级,比如将用户信息.ClientDetails.token存入数据库而非内存.配置 ...

  5. Spring security oauth2最简单入门环境搭建

    关于OAuth2的一些简介,见我的上篇blog:http://wwwcomy.iteye.com/blog/2229889 PS:貌似内容太水直接被鹳狸猿干沉.. 友情提示 学习曲线:spring+s ...

  6. Spring Security Oauth2系列(一)

    前言: 关于oauth2,其实是一个规范,本文重点讲解spring对他进行的实现,如果你还不清楚授权服务器,资源服务器,认证授权等基础概念,可以移步理解OAuth 2.0 - 阮一峰,这是一篇对于oa ...

  7. spring security oauth2 jwt 认证和资源分离的配置文件(java类配置版)

    最近再学习spring security oauth2.下载了官方的例子sparklr2和tonr2进行学习.但是例子里包含的东西太多,不知道最简单最主要的配置有哪些.所以决定自己尝试搭建简单版本的例 ...

  8. Spring Security OAuth2 Demo -- good

    1. 添加依赖授权服务是基于Spring Security的,因此需要在项目中引入两个依赖: <dependency> <groupId>org.springframework ...

  9. Spring Security Oauth2 permitAll()方法小记

    黄鼠狼在养鸡场山崖边立了块碑,写道:"不勇敢地飞下去,你怎么知道自己原来是一只搏击长空的鹰?!" 从此以后 黄鼠狼每天都能在崖底吃到那些摔死的鸡! 前言 上周五有网友问道,在使用s ...

  10. 使用Spring MVC测试Spring Security Oauth2 API

    不是因为看到希望了才去坚持,而坚持了才知道没有希望. 前言 在Spring Security源码分析十一:Spring Security OAuth2整合JWT和Spring Boot 2.0 整合 ...

随机推荐

  1. springdata(jpa)的基础使用

    jpa与mybatis-plus类似,都属于数据库相关的框架 jpa需要扫描,这里在启动类指定路径 jpa的实体类需要绑定@Entity, 与mysql表映射@Table(@name="数据 ...

  2. 【vscode】linux下vscode的使用

    注1:vscode在查看project时,非常好用,可以导入整个project并查看其中文件,通过插件的安装还可以实现跳转到当前函数定义处的功能; 注2:可以了解下source insight; 补充 ...

  3. 更改ubuntu分辨率

    显示器是1920*1080的,ubuntu20里没有,查了一通,修改成功,过程如下: 1.打开终端,输入xrandr, 我用的虚拟机,记下Virtual1 connected primary 1920 ...

  4. nohup文件的压缩分割

    编写sh脚本 先拷贝,之后,清空. 待完成,压缩功能 #!/bin/sh #description split logs time1=$(date -d 'yesterday' "+%Y%m ...

  5. [CSP-S2019] Emiya 家今天的饭

    洛咕 题意:原题面见链接,简单来说就是给出一个\(n*m\)的矩阵,每一行代表同一种烹饪方法,每一列代表同一种食材,\(a_{i,j}\)表示使用第i种烹饪方法第j种食材能做出多少种菜,要求至少做一道 ...

  6. servlet和spring框架的关系

    1.Servlet是什么? servlet就是一个Java接口,是JavaEE规范的一种,主要是为了扩展Java作为Web服务的功能. 由其他内部厂商如tomcat,JBoss内部实现web的功能. ...

  7. 关于pytorch一些基础知识的备份

    压缩conda环境用于备份目的实际上没有意义,因为还有其他方法可以做到这一点,这可能更合适,并使用专为此而设计的内置功能. 您可以创建一个环境.txt版本conda,详细说明其中的每个模块和版本,然后 ...

  8. js时间戳转换

    第一个参数传时间戳,第二个连接符可以看你的心情,我喜欢'-' formatDate(value, spe = '/') { value = value * 1000 //10位数时间戳要乘1000 1 ...

  9. php递归算法多级分类

    /** * 递归实现无限极分类 * @param $array 分类数据 * @param $pid 父ID * @param $level 分类级别 * @return $list 分好类的数组 直 ...

  10. Day 11 11.2 文件操作

    文件操作 引言 到目前为止,我们做的一切操作,都是在内存里进行的,这样会有什么问题吗?如果一旦断电或发生意外关机了,那么你辛勤的工作成果将瞬间消失.是不是感觉事还挺大的呢?现在你是否感觉你的编程技巧还 ...