我的spring boot應用程式因為這個錯誤而無法啟動。一個組件需要一個名為'sessionScopedLdapUser'的bean,但無法找到
我的Bean被定義在這個類中:
@Configuration
public class RestTemplateClient {
Logger logger = LoggerFactory.getLogger(SwitchController.class)。
@Bean
公共RestTemplate restTemplate() {
回傳新的RestTemplate()。
}
@Bean("sessionScopedLdapUser"); /************** <----
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public LdapUser requestScopedBean() {
logger.info("LdapUser bean instance created")。
return new LdapUser();
}
我在我的服務類中使用該Bean:
@Service
public class IsimRestApiImpl implements IsimRestApiService{
@Autowired
private RestTemplate restTemplate。
@Resource(name = "sessionScopedLdapUser")
LdapUser sessionScopedLdapUser。
我不確定我在配置中做錯了什么。如果我在我的配置中添加bean的名字(箭頭所在的位置),我得到了 uj5u.com熱心網友回復: 會不會是與你的bean的范圍有關呢?我也覺得你不應該給Bean一個名字。如果你只做一個LdapUser型別的Bean,在我看來就沒有必要了...... 我可以試著洗掉Bean的名字。
我會嘗試從Bean中移除名稱和范圍,看看你的應用程式是否能啟動。在添加一些選項并找出它到底哪里出了問題之前。
標籤: 上一篇:TypeError:firebase_compat_app__WEBPACK_IMPORTED_MODULE_0__.default.firestore不是一個函式。
下一篇:如何檢查輸入是否與字串相同這里不允許注釋。
