Spring报错解决一览

2023-05-16

Spring错误持续更新贴......     

问题一

springcloud-OAuth2.0配置的时候报错

Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a bean of type 'org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory' that could not be found.

The following candidates were found but could not be injected:
    - Bean method 'userInfoRestTemplateFactory' in 'ResourceServerTokenServicesConfiguration' not loaded because @ConditionalOnMissingBean (types: org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration; SearchStrategy: all) found beans of type 'org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration' org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory' in your configuration.

问题原因:

(1)做服务器端OAuth,引用了客户端的相关jar,并且还没有配置;

问题二:

spring cloud security oauth2.0 默认是禁用Client模式进行授权的;Oauth2.0 client模式无法授权;

allowFormAuthenticationForClients()方法开启;

问题三:

密码模式获取token的情况下, Basic校验写错了

{
    "timestamp": "2019-05-16T15:31:11.450+0000",
    "status": 401,
    "error": "Unauthorized",
    "message": "Unauthorized",
    "path": "/oauth/token"
}

解决: 这个一种情况是Basic用户名密码写错了,在拦截器BasicAuthenticationFilter中校验不通过抛出异常

问题三:springSeurity明明配置了password授权,但是在做改动的时候提示如下

{
    "error": "unsupported_grant_type",
    "error_description": "Unsupported grant type: password"
}

解答: AuthorizationServerEndpointsConfigurer类中获取所有的granter的时候,需要判断authenticationmananager是否为空,才能默认加载password权限分配器

问题四:
java.lang.IllegalStateException: Cannot apply org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer@6d8b7ea9 to already built object
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.add(AbstractConfiguredSecurityBuilder.java:196) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.apply(AbstractConfiguredSecurityBuilder.java:133) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.builders.HttpSecurity.getOrApply(HttpSecurity.java:1501) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.builders.HttpSecurity.authorizeRequests(HttpSecurity.java:654) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer.configure(ResourceServerSecurityConfigurer.java:222) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
    at org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer.configure(ResourceServerSecurityConfigurer.java:59) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.configure(AbstractConfiguredSecurityBuilder.java:384) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:330) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.builders.WebSecurity.performBuild(WebSecurity.java:294) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.builders.WebSecurity.performBuild(WebSecurity.java:79) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.AbstractConfiguredSecurityBuilder.doBuild(AbstractConfiguredSecurityBuilder.java:334) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:41) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:104) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$415a6f9.CGLIB$springSecurityFilterChain$2(<generated>) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$415a6f9$$FastClassBySpringCGLIB$$55f25315.invoke(<generated>) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$415a6f9.springSecurityFilterChain(<generated>) ~[spring-security-config-5.1.4.RELEASE.jar:5.1.4.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    ... 22 common frames omitted
问题5:
{
    "error": "invalid_token",
    "error_description": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsidXNlci1zZXJ2aWNlcyJdLCJleHAiOjE1NTg2NzcwNjgsInVzZXJfbmFtZSI6ImFkbWluIiwianRpIjoiYjlkMjY5YjgtOGE4Yi00ZDI1LTk4YzktMzkwNzRlNGNhMzk3IiwiY2xpZW50X2lkIjoibGl4aWFvaGFvIiwic2NvcGUiOlsidXNlciJdfQ.Pa03fAoN0APHQMh5FSUWRtxtQbn5vVN1JQGLu-Ql8k4"
}
解决: 原因多样,总的来说就是去服务器端根据token查询用户信息错误(1)就是token失效等 (2)地址在没有配置ssl的时候使用https等
问题6:
{
    "error": "access_denied",
    "error_description": "Invalid token does not contain resource id (oauth2-resource)"
}
解决: 用户去资源服务器锁清秋的资源标识,在token中不存在; 如你生成的token中可用资源包括 查询用户信息,但是在请求用户信息的时候,它有拦截会查看你token中的标识是否跟自己的标识相同
问题7:
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
解决:请求协议不一致,应该都为http或https
问题8:
Caused by: feign.FeignException: status 403 reading OAuthUserService#testautherization()
    at feign.FeignException.errorStatus(FeignException.java:78)
    at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:93)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:149)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
    at com.sun.proxy.$Proxy138.testautherization(Unknown Source)
    at com.enci.test.server.module.controller.PolicyController.feignRequest(PolicyController.java:151)
    at com.enci.test.server.module.controller.PolicyController$$FastClassBySpringCGLIB$$c9349f5f.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
    at com.enci.test.server.module.controller.PolicyController$$EnhancerBySpringCGLIB$$6f5b74e0.feignRequest(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
    ... 102 more
解决:权限不足, 获取的token中锁允许访问的resource与实际访问的resource信息不匹配,被拒绝访问
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring报错解决一览 的相关文章

随机推荐

  • Linux_CenterOS环境下JDK安装

    JDK配置 1 卸载已有的open jdk 查看目前已有的JDK rpm qa grep jdk 输出如下 copy jdk configs 3 3 10 el7 5 noarch java 1 8 0 openjdk 1 8 0 181
  • 树莓派上设置程序开机自启动

    方法一 xff1a 向rc local文件添加启动代码 修改rc local文件 xff1a sudo nano etc rc local 在打开的rc local找到exit 0 xff0c 在exit 0 之前添加一行代码 xff1a
  • smartcar仿真学习记录

    操作系统 xff1a ubuntu 18 04 ROS版本 xff1a melodic 本记录是跟随古月居的smartcar教程进行学习的 终端 文件夹下的操作 首先创建目录 也就是catkin ws src mkdir p smartca
  • 在树莓派上手动添加ROS包(usb_cam)

    在ROS下 xff0c 下载包源码编译后 xff0c 手动添加包 系统 xff1a ubuntu1804 xff08 树莓派 xff09 在树莓派上安装了ubuntu xff0c 但树莓派是arm架构 xff0c 所以用的下载源也不同于在电
  • /etc/apt/sources.list

    统一格式 xff1a deb https A B C main restricted universe multiverse deb src https A B C main restricted universe multiverse d
  • WARNING: pip is being invoked by an old script wrapper.

  • Keil 添加库文件(xxx.h)路径

  • 时间复杂度中的log(n)底数到底是多少?

    其实这里的底数对于研究程序运行效率不重要 xff0c 写代码时要考虑的是数据规模n对程序运行效率的影响 xff0c 常数部分则忽略 xff0c 同样的 xff0c 如果不同时间复杂度的倍数关系为常数 xff0c 那也可以近似认为两者为同一量
  • ubuntu1804(树莓派)使用AV接口播放音频问题

    2条消息 在运行ubuntu 18 04的树莓派上播放声音 Qrpucp的博客 CSDN博客 config txt还需加入 audio pwm mode 61 2
  • 在Modelsim内编辑testbench并重新仿真

    方法同样适用于编辑 v文件
  • 【SSH连接阿里云服务器失败解决办法】

    SSH连接阿里云服务器失败解决办法 1 添加安全组规则 找到要修改的实例 点击实例名 xff0c 进入实例详情界面 xff0c 点击 配置安全组规则 点击配置规则 添加一条如下图所示的入方向端口22 测试连接是否成功 xff0c 若不成功
  • sklearn实战-----6.聚类算法K-Means

    1 概述 1 1 无监督学习与聚类算法 在过去的五周之内 xff0c 我们学习了决策树 xff0c 随机森林 xff0c 逻辑回归 xff0c 他们虽然有着不同的功能 xff0c 但却都属于 有监督学习 的一部分 xff0c 即是说 xff
  • 过于神奇的 ChatGPT

    实在好奇究竟用的什么数据集 xff0c 居然能得到下述问答 xff1a 最后又扣回了第一个问题 按照你的要求直接给出答案 xff0c 确实很强 xff01
  • 优质 CS 读博 (PhD) 经验贴汇总

    前言 如果你对这篇文章感兴趣 xff0c 可以点击 访客必读 指引页 一文囊括主页内所有高质量博客 xff0c 查看完整博客分类与对应链接 Advice for early stage Ph D students 读博的核心是在研究上取得进
  • 推荐系统中的协同过滤算法

    前言 如果你对这篇文章感兴趣 xff0c 可以点击 访客必读 指引页 一文囊括主页内所有高质量博客 xff0c 查看完整博客分类与对应链接 概述 协同过滤是一种推荐算法 xff0c 其通常建模为 m m m 个用户 xff0c n
  • 哈希函数的学习算法整理

    前言 如果你对这篇文章感兴趣 xff0c 可以点击 访客必读 指引页 一文囊括主页内所有高质量博客 xff0c 查看完整博客分类与对应链接 概述 哈希函数学习的两个步骤 xff1a 转为二进制编码 xff1a 可以先降维成实数 xff0c
  • O(1) 的离散概率分布采样方法 - Alias Method

    前言 如果你对这篇文章感兴趣 xff0c 可以点击 访客必读 指引页 一文囊括主页内所有高质量博客 xff0c 查看完整博客分类与对应链接 Alias Method 给定一个离散概率分布 p 61 0 3
  • 变分推断 (Variational Inference) 解析

    前言 如果你对这篇文章感兴趣 xff0c 可以点击 访客必读 指引页 一文囊括主页内所有高质量博客 xff0c 查看完整博客分类与对应链接 变分推断 在贝叶斯方法中 xff0c 针对含有隐变量的学习和推理 xff0c 通常有两类方式 xff
  • 通过ssh连接aws(亚马逊 云服务器 实例)

    一 Windows用户 windows可以使用PuTTY 和xshell xff0c 本文使用xshell xff08 1 xff09 第一步 xff1a 配置服务器信息 打开xshell xff0c 新建连接 xff0c 在菜单 连接 填
  • Spring报错解决一览

    Spring错误持续更新贴 问题一 springcloud OAuth2 0配置的时候报错 Method springSecurityFilterChain in org springframework security config an