Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationMana
Posted VipSoft
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationMana相关的知识,希望对你有一定的参考价值。
Consider defining a bean of type \'org.springframework.security.authentication.AuthenticationManager\' in your configuration.
[2023-04-25 14:44:36.426] [main] [ERROR] o.s.b.diagnostics.LoggingFailureAnalysisReporter -
***************************
APPLICATION FAILED TO START
***************************
Description:
Field authenticationManager in com.vipsoft.web.security.AuthorizationService required a bean of type \'org.springframework.security.authentication.AuthenticationManager\' 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.authentication.AuthenticationManager\' in your configuration.
Disconnected from the target VM, address: \'127.0.0.1:10059\', transport: \'socket\'
Process finished with exit code 1
在 authenticationManagerBean
加上 @Bean
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter
/**
* 解决 无法直接注入 AuthenticationManager
*
* @return
* @throws Exception
*/
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception
return super.authenticationManagerBean();
Consider defining a bean of type问题解决
背景
项目越来越大,拆包成为了必然之路。
因为原来的项目的单体的,不可能直接转换为分布式,那么只能先拆包,把前后台拆分出来两个单独的接口访问地址。
问题
拆包之后,发现项目直接报错Consider defining a bean of type。
解决
这个问题主要是因为项目拆包后,在原有的引用项目中无法找到对应的包的路径。
所以,解决方法是让原来引用的项目可以找到资源的路径就可以了。
在项目的Application启动文件里,使用@MapperScan注解,把当前的路径引用进去就可以了。
总结
拆包路上,问题多多,遇水搭桥这个是必然之路,没有一步登天的事情
以上是关于Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationMana的主要内容,如果未能解决你的问题,请参考以下文章
springboot Consider defining a bean of type 'xxx' in your configuration
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationMana
Consider defining a bean of type问题解决
MapStruct - Consider defining a bean of type in your configuration.
Consider defining a bean of type `xxx` in your configuration问题解决问题解决
Spring Boot @Autowired无法注入类 Consider defining a bean of type