Pokud chcete Printer konfigurovat manuálně v XML, odstraňte z Printer anotaci @Component, aby ji nenašel context:component-scan
Martin Caslavsky 2010/9/10 Dusan Msk <[email protected]>: > Ahoj. > > Mam spring kontext v javase aplikacii, zlozeny z: > > ifc PrinterBase { ... } > @Component class Printer implements PrinterBase { > private Messager messager; > } > > ifc Messager { ... } > @Component class MessagerA implements Messager { ... } > @Component class MessagerB implements Messager { ... } > > ... a dalsie (unikatne) komponenty, ktore sa mi nechce explicitne > vymenovavat v xml. > > Chcel by som docielit toho, ze kontext bude vyskladany pomocou > autowire+scan, ale konkretne u komponenty Printer chcem manualne > specifikovat, ci sa ma pouzit MessagerA alebo MessagerB. Myslim, ze to je > vcelku obvykly poziadavok v modularnej aplikacii, takze by to nejak > mohli ist. > > Laboroval som s nasledovnym (nefunkcnym) kontextovym xml, ale spring hlasi, > ze si nevie vybrat medzi MessagerA a MessagerB v autowire: > > <!-- snazim sa mu vnutit MessagerB --> > <bean id="printer" class="cz.test.Printer" autowire="no"> > <property name="messager" ref="messagerB"/> > </bean> > > > <!-- ale nez sa mi to podari, autowire vyhodi vynimku --> > <context:annotation-config/> > <context:component-scan base-package="cz.test"/> > > <!-- skusal som aj odkomentovat manualnu specifikaciu MessagerB > <bean id="messagerB" class="cz.test.MessagerB"/> > ale bez vysledku --> > > > > Je vobec mozne takto konfiguraciu skombinovat? > > -- > Diky > > Dusan >
