【发布时间】:2021-01-18 18:22:48
【问题描述】:
我正在尝试使用配置文件在我的服务类中自动装配密码编码器:
@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.
【问题讨论】:
标签: spring spring-boot spring-security