For example, I created many “test-my-service” objects in my Spring configuration, and each object has data related to a fake test case. Currently, I manually edit the Spring configuration every time I want to run a new script, or Script List. Is there a way to add a prefix to the bean name and then load all the beans with this prefix (or suffix) into a list or array? Sort of....
<bean name="env1-test1"/> <bean name="env2-test1"/>
This is the code that I wrote in the letter. I could not get the beanFactory object initialized from the example I accepted earlier:
String[] beanNames = context.getBeanNamesForType(Inputs.class); for (String beanName : beanNames) { if (beanName.startsWith("env")) { System.out.println("Found a bean of type " + Inputs.class.getName()); Inputs bean = (Inputs)context.getBean(beanName); doTest(bean); } }
source share