第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關(guān)于bean的詳細(xì)問題,請看下面具體情況

關(guān)于bean的詳細(xì)問題,請看下面具體情況

三國紛爭 2021-06-16 15:11:15
spring mvc 里@Autowired自動注入的bean(jdbcTemplate) 和ApplicationContext的getBean()方法獲取的bean竟然不是同一個bean(hashCode不一樣),請問怎么手動獲取和@Autowired自動注入的一樣的bean呀???
查看完整描述

2 回答

?
小怪獸愛吃肉

TA貢獻(xiàn)1852條經(jīng)驗 獲得超1個贊

當(dāng)然不一樣。我今天在做springbatch的 job時遇到了同樣的問題,到谷歌搜了一下:
A bean with scope prototype just means that everytimeApplicationContext.getBean is called a new instance of the bean is created. If you try to inject a prototype bean in a singleton, your prototype bean will be injected once (and so is no more a prototype).
大意就是說spring管理的bean默認(rèn)是單例模式,這種情況下autowired和getbean拿到的沒區(qū)別,但是如果你加入了@Scope(SCOPE_PROTOTYPE)那么就必須用getbean去拿否則這個注解沒有任何意義

查看完整回答
反對 回復(fù) 2021-06-21
?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗 獲得超7個贊

一個是啟動是自動注入的,一個是獲取的..感覺是這樣..

查看完整回答
反對 回復(fù) 2021-06-21
  • 2 回答
  • 0 關(guān)注
  • 367 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號