java - Switch between two beans in spring -


I have two beans that come from the same class (id 1 and id 2), difference id and some properties. In code, I get called getbean (id1) to get the object

How do I switch to id2 without compiling the code again?

If you have two different bean wisdom different properties mean that you have two separate- There are different objects that means you will deal with them because you will normally treat various items -

  beacon b1 = (beacon) CTX .get bean ("id1"); BeanClass B2 = (Beanclass) CTX .get Bean ("ID2");   

However, if you have different scanners where you load the bean 1 in your class for normal working and when you run it through the juneet, then you have a different perspective -

Keep two different applicationContext.xml files when your code runs through JUNIT, then the first one loads when your code runs and then another (applicationContext) -test.xml) This way you can change the code Can Load Different Beans Without

Comments