java - Can I change the implementation class injected by spring in runtime? -


i have class has injected spring on applicationcontext.xml , need change implementation without change applicationcontext.xml.

i heard aop "introductioninterceptor" don't found many useful results.

anyone can me?

ps. sorry bad english, hope give understand.

you can in several ways, here few:

  1. write xml file, override configuration adding same bean id , implementation class want use, import new xml existing application context.

  2. through code, base on need can set new implementation before calling code.

there more have used '1' in number of projects.

if have multiple beans same id, spring pickup latest one, e.g.

<beans>    <import resource="a.xml"/>    <import resource="b.xml"/> </beans> 

now if both a.xml , b.xml have bean defined same id, spring use bean defined in b.xml.

cheers !!


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -