Tak tu beanu vylučte z component-scan přes exclude-filter. Martin Caslavsky
2010/9/13 Dusan Msk <[email protected]>: > Hmm, > > oba uvedene pripady ale vyzaduju zasah do kodu ( odstranit @Component, > pridat @Qualifier ). > Co ked ale povodny autor kodu nepocital z moznostou nahradit jeho komponent > inou implementaciou ( tzn. pouziva sa @Component a zaroven autowiring )? > > -- > Dusan > > > Dňa 10. septembra 2010 21:00, Roman Pichlík <[email protected]> > napísal(-a): >> >> Nechapu proc nepouzijete id komponenty? >> >> @Component >> class Printer implements PrinterBase { >> �...@autowire("MessagerA") >> private Messager messager; >> >> } >> >> >> @Component("MessagerA") >> public class MessagerA{ >> } >> >> Samozrejme se to udelat i typove a ne binding skrze idcko viz 3.11.3. >> Fine-tuning annotation-based autowiring with qualifiers >> >> http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-autowired-annotation >> >> >> >> 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 >> > >> >> >> >> -- >> S pozdravem Roman "Dagi" Pichlik >> >> /* http://dagblog.cz/ Blog pro kodery */ > >
