异常信息为

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. vue2的响应式原理

    响应式的话,主要指的是这个状态改变以后,视图要去主动更新 这个过程,vue是通过两个步骤来实现的 1 数据的劫持 数据劫持也叫做数据拦截,通过Object.defineProperty来把对象中的每一 ...

  2. Doris使用记录

    创建分区表: CREATE TABLE `test_partitioned` ( `gmt_create` datetime NULL COMMENT "创建时间", `colum ...

  3. 百题计划-6 codeforces 651 div2 E. Binary Subsequence Rotation 01序列集合划分,2个队列处理

    https://codeforces.com/contest/1370/problem/E 队列元素以末尾字符为结尾的序列就好了,这里队列里的元素不重要,队列size重要 #include<bi ...

  4. ESXi 基础安全加强(ing...)

    # 查看防火墙规则esxcli network firewall ruleset allowedip list # 允许指定ip使用web服务和客户端访问[root@localhost:~] esxc ...

  5. k8s_使用k8s部署博客系统deployment(四)

    mysql deployment 前面的nfs  pv pvc secret configmap service等k8s对象已经创建好了,准备工作已经完成:现在可以开始准备deployment配置文件 ...

  6. dynamics 365/crm 导入解决方案报 发生 sql server 错误

    dynamics 365/crm 导入解决方案报 发生 sql server 错误.{1}{0} 错误代码 80044150. 帮助我解决此问题. 这时候,可以检查数据库服务器的日志看看,可能会找到S ...

  7. 设置eclipse默认编码为UTF-8 Set default encoding to utf-8 in eclipse

    设置eclipse默认编码为UTF-8 Set default encoding to utf-8 in eclipse 1,windows->Perferences->General-& ...

  8. 学习Anaconda,jupyter notebook

    20200210,理解了jupyter在anaconda中的意义,vs code觉得对我这个初学者来讲,更容易使用,pycharm虽然破解安装了,但是感觉不太好用,随后再说 20200211, jup ...

  9. Vue 收集表单数据-输入input,单选radio,多选checkbox,下拉框select ,以及v-model的3个修饰符(lazy,number,trim)

    From案例分析: 1.Html 部分: <form @submit.prevent="" style=" border: 1px solid rgb(109, 2 ...

  10. PO 锁

    SAP NetWeaver Administrator->可用性和监控->资源监控->锁