spring-security-oauth2使用遇到的坑
异常信息为
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使用遇到的坑的更多相关文章
- Spring Boot 中使用 Spring Security, OAuth2 跨域问题 (自己挖的坑)
使用 Spring Boot 开发 API 使用 Spring Security + OAuth2 + JWT 鉴权,已经在 Controller 配置允许跨域: @RestController @C ...
- Spring Security OAuth2学习
什么是 oAuth oAuth 协议为用户资源的授权提供了一个安全的.开放而又简易的标准.与以往的授权方式不同之处是 oAuth 的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需 ...
- 【OAuth2.0】Spring Security OAuth2.0篇之初识
不吐不快 因为项目需求开始接触OAuth2.0授权协议.断断续续接触了有两周左右的时间.不得不吐槽的,依然是自己的学习习惯问题,总是着急想了解一切,习惯性地钻牛角尖去理解小的细节,而不是从宏观上去掌握 ...
- 使用Spring Security Oauth2完成RESTful服务password认证的过程
摘要:Spring Security与Oauth2整合步骤中详细描述了使用过程,但它对于入门者有些重量级,比如将用户信息.ClientDetails.token存入数据库而非内存.配置 ...
- Spring security oauth2最简单入门环境搭建
关于OAuth2的一些简介,见我的上篇blog:http://wwwcomy.iteye.com/blog/2229889 PS:貌似内容太水直接被鹳狸猿干沉.. 友情提示 学习曲线:spring+s ...
- Spring Security Oauth2系列(一)
前言: 关于oauth2,其实是一个规范,本文重点讲解spring对他进行的实现,如果你还不清楚授权服务器,资源服务器,认证授权等基础概念,可以移步理解OAuth 2.0 - 阮一峰,这是一篇对于oa ...
- spring security oauth2 jwt 认证和资源分离的配置文件(java类配置版)
最近再学习spring security oauth2.下载了官方的例子sparklr2和tonr2进行学习.但是例子里包含的东西太多,不知道最简单最主要的配置有哪些.所以决定自己尝试搭建简单版本的例 ...
- Spring Security OAuth2 Demo -- good
1. 添加依赖授权服务是基于Spring Security的,因此需要在项目中引入两个依赖: <dependency> <groupId>org.springframework ...
- Spring Security Oauth2 permitAll()方法小记
黄鼠狼在养鸡场山崖边立了块碑,写道:"不勇敢地飞下去,你怎么知道自己原来是一只搏击长空的鹰?!" 从此以后 黄鼠狼每天都能在崖底吃到那些摔死的鸡! 前言 上周五有网友问道,在使用s ...
- 使用Spring MVC测试Spring Security Oauth2 API
不是因为看到希望了才去坚持,而坚持了才知道没有希望. 前言 在Spring Security源码分析十一:Spring Security OAuth2整合JWT和Spring Boot 2.0 整合 ...
随机推荐
- SpringCloud-Study
SpringCloud-Study 一.微服务简介 1.单体架构和分布式架构 单体架构 分布式架构 分布式架构的问题 解决方案 小结 2.微服务 微服务技术 微服技术对比 3.SpringCloud ...
- springsecurity maven 打包后,404错误。maven 打包后,加载内置的xml文件
404错误,解决的办法,主要是pom文件 <build> <resources> <resource> <directory>src/main/reso ...
- 监控本机环境生成SQL脚本
在开发工作中我们客户端连接 测试服务器开发工作,往往很多人操作数据库,如何甄别出自己操作 方法一: 在程序配置节点设置App节点,譬如: <add name="ModelEntitie ...
- mybatis 一级、二级缓存机制
MyBatis 提供了对缓存的支持,分为一级缓存和二级缓存 一级缓存是 SqlSession 级别的缓存.在操作数据库时需要构造 SqlSession 对象,在对象中有一个数据结构(HashMap)用 ...
- ReactJS单页面应用之项目搭建
初衷 因接手的项目前端采用reactjs+antd,为把控项目中的各个细节,所以想做一些整理,以免后期遗忘. 创建及启动项目 # 全局安装create-react-app # 如果曾经安装过,可先移除 ...
- 86、linux离线安装nginx
参考 nginx 离线安装https://blog.csdn.net/ywd1992/article/details/83095855
- P8201 [传智杯 #4 决赛] [yLOI2021] 生活在树上(hard version)
个人思路: 首先,题目可以转化为是否存在 \(a,b\) 路径上一点 \(u\),满足 \(w_u = dis{1,a} \oplus dis{1,b} \oplus w_{lca(a,b)} \op ...
- jmeter非GUI模式运行-分布式测试
上一篇文章我们说到了jmeter命令行运行但是是单节点下的, jmeter底层用java开发,耗内存.cpu,如果项目要求大并发去压测服务端的话,jmeter单节点难以完成大并发的请求,这时就需要对j ...
- Unity多线程使用(线程池)
1.在C#中使用线程池需要以下这个类库using System.Threading 2.开单个线程(unity程序停止前 线程一定要关闭) private Thread tempThread; voi ...
- js常用遍历理解
1.for循环用于数组的遍历循环. 2.for in 循环主要用于遍历普通对象,i 代表对象的 key 值,a[i] 代表对应的 value. 3.forEach循环 遍历数组中的每一项,没有返回值, ...