我想了解從Spring使用xml註釋到基於java的批註的過渡。我有這些定義:什麼是您將在Spring中使用@Configuration和@ComponentScan的特定用例?
<context:annotation-config>: Scanning and activating annotations for already registered beans in spring config xml.
<context:component-scan>: Bean registration + <context:annotation-config>
是@Configuration並且是@ComponentScan。
如果我們說我用@Component聲明瞭所有的bean(首先忽略@Repository,@Service等更具體的註釋)註釋,並確保包由@ComponentScan註釋掃描,那麼什麼是特定的用例,我仍然會用@ComponentScan和@Configuration來註釋我的類。
我問這個問題,因爲有時候我看到類同時用@Configuration和@ComponentScan註解。