1、应用服务基路径问题
这个问题应该是Spring Boot 2.0升级带来的,既然遇到了,就在这里写一写。笔者在授权服务器想设置一个统一基路径,按照Spring Boot 1.0,是这样的:
server.context-path=/xxx
但是升级之后并不好使,最后看官方文档发现改掉了,现在是这样的:
server.servlet.context-path=/xxx
2、AuthenticationManager无法注入
在覆写
AuthorizationServerConfigurerAdapter
类的
public void configure(AuthorizationServerEndpointsConfigurer endpoints)
方法时,往往需要显式注入
AuthenticationManager
,但是在5.x版本中,启动会报如下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field authenticationManager in cn.springcloud.book.OAuthConfiguration required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
解决方案:
在启动主类继承
WebSecurityConfigurerAdapter
类同时,手动注入:
@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
3、登陆报错:There is no PasswordEncoder mapped for the id “null”
在使用Spring Security 5.x登陆页面进行登陆时,后端会报错:There is no PasswordEncoder mapped for the id “null”,因为5.x版本新增了多种密码加密方式,必须指定一种,比如这样解决:
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
下列加密方式供参考,选取一种即可:
bcrypt - BCryptPasswordEncoder (Also used for encoding)
ldap - LdapShaPasswordEncoder
MD4 - Md4PasswordEncoder
MD5 - new MessageDigestPasswordEncoder("MD5")
noop - NoOpPasswordEncoder
pbkdf2 - Pbkdf2PasswordEncoder
scrypt - SCryptPasswordEncoder
SHA-1 - new MessageDigestPasswordEncoder("SHA-1")
SHA-256 - new MessageDigestPasswordEncoder("SHA-256")
sha256 - StandardPasswordEncoder
1、应用服务基路径问题这个问题应该是Spring Boot 2.0升级带来的,既然遇到了,就在这里写一写。笔者在授权服务器想设置一个统一基路径,按照Spring Boot 1.0,是这样的:server.context-path=/xxx但是升级之后并不好使,最后看官方文档发现改掉了,现在是这样的:server.servlet.context-path=/xxx2、AuthenticationMan
赠送jar包:
spring-
security-web-5.2.0.RELEASE.jar;
赠送原API文档:
spring-
security-web-5.2.0.RELEASE-javadoc.jar;
赠送源代码:
spring-
security-web-5.2.0.RELEASE-sources.jar;
赠送Maven依赖信息文件:
spring-
security-web-5.2.0.RELEASE.pom;
包含翻译后的API文档:
spring-
security-web-5.2.0.RELEASE-javadoc-API文档-中文(简体)版.zip;
Maven坐标:
org.
springframework.
security:
spring-
security-web:5.2.0.RELEASE;
标签:
springframework、
security、
spring、web、中文文档、jar包、java;
使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。
人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心使用。
SpringBoot Consider defining a bean of type `xxx` in your configuration 错误情况解决(Spring、feign等)
<dependency>
<groupId>
org.
springframework.cloud</groupId>
<ar
tifac
tId>
spring-cloud-starter-gateway</ar
tifac
tId>
<dependency>
Descrip
tion:
Parameter 0 of method modifyRequestBodyGatewayFilterFactory in
org.
springframework.cloud.gateway.config.Gateway
AutoConfigura
tion required a
bean of
type ‘
org.
springframework.http.codec.ServerCodecConfigurer’ that could not be found.
Ac
tion:
最近遇到一个问题,项目之前使用了Redis,可正常启动,然后最近对Redis部分进行了一些微调,再启动服务提示如下错误:
Consider defining a
bean of
type '
org.
springframework.data.redis.core.RedisTemplate' in your configura
tion.
出现该错误的原因可能有很多,
记录下几种解决办法。
1、
SpringBoot版本问题:
pom.xml中如果有配置
<dependency>
报错信息:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2020-05-15 00:05:12 ERROR [main]o.s.b.d.LoggingFailureAnalysisReporter [LoggingFailureAnalysisReporter.java : 40] -
APPLICATION FAILED
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u012377333/ar
ticle/details/84376251
在更换
spring-boot-
auto-config的版本从1.5.13升级至2.0.6的过程中出现问题
<dependency>
今天在写新服务时忽然报了这个错误:
Consider defining a
bean of
type;大意为考虑定义一种类型的
bean,也会是说你的管理工具没找到你要的那个类,根据这个想法,试着从起点找了一下,实现类是否有@Service注解,包位置是否有问题。于是便找到了问题的来历,没有在实现类上放注解,导致
spring无法找到相应
bean,无法完成注入,于是报错。