我正在尝试使用配置文件自动连接服务类中的密码编码器:
@Configuration
@EnableWebSecurity
class SecurityConfiguration : WebSecurityConfigurerAdapter() {
@Bean
fun passwordEncoder(): PasswordEncoder {
return BCryptPasswordEncoder()
}
intellij将@autowired var passwordencoder检测为autowired的候选。
@Service
class userServiceImpl : UserService {
@Autowired
private lateinit var passwordEncoder : PasswordEncoder
我知道调用配置是因为调用了配置文件的其他元素。
***************************
APPLICATION FAILED TO START
***************************
Description:
Field passwordEncoder in com.example.project.service.userServiceImpl required a bean of type 'org.springframework.security.crypto.password.PasswordEncoder' 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.crypto.password.PasswordEncoder' in your configuration.
1条答案
按热度按时间g52tjvyc1#
我在我的主类中为有问题的包添加了一个组件扫描注解,这样就消除了错误