【发布时间】:2018-12-20 01:04:47
【问题描述】:
我有一个具有相当标准配置和安全配置的 JHipster 5.3.4 项目,但是在尝试运行该项目时,我收到以下错误,表示缺少 bean。
在 root/config/SecurityConfiguration.java 我有以下类头和内部 bean
@Configuration
@Import(SecurityProblemSupport.class)
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
...
@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
...
}
在 root/web/rest/UserJWTController.java 我有以下内容
@RestController
@RequestMapping("/api")
public class UserJWTController {
private final TokenProvider tokenProvider;
private final AuthenticationManager authenticationManager;
public UserJWTController(TokenProvider tokenProvider,
AuthenticationManager authenticationManager) {
this.tokenProvider = tokenProvider;
this.authenticationManager = authenticationManager;
}
...
但是当我尝试运行该项目时,我得到: au.com.suncorp.pp.web.rest.UserJWTController 中构造函数的参数 1 需要 'org.springframework.security.authentication.AuthenticationManager' 类型的 bean
我假设有一个 bean 构建排序问题,但我没有我的元素。有人可以帮忙吗?
【问题讨论】:
-
移除 authenticationManagerBean()
-
为什么?这是应用程序中任何位置的 AuthenticationManager 的唯一构造函数。它还会去哪里?
-
提问之前,有没有试过把它去掉,看看有没有错误?
-
与以前完全相同的错误。
-
UserJWTController 中需要 AuthenticationManager 的确切代码是什么?
标签: java spring spring-boot jhipster