Hello,
Is it possible to use multiple xml configuration files for one context?
I have a very large config file that I would like to cut in separate parts but i need to make cross references between beans defined in the different parts.
thanks
Hello,
Is it possible to use multiple xml configuration files for one context?
I have a very large config file that I would like to cut in separate parts but i need to make cross references between beans defined in the different parts.
thanks
See Spring Reference Guide section 3.15, "Creating an ApplicationContext from a web application", for details on how to do this in a webapp.
In a non-webapp situation (eg unit test) you just do this:
Code:private String[] configLocations = {"/appctx-datastore.xml", "/appctx-security-relaxed.xml"}; new ClassPathXmlApplicationContext(configLocations);
And can we reference beans from one file to another?
I found a post that indicatees that this is doable but when we tried it and we used <ref bean= instead of ref local, but we still got an error from Spring telling us:
"An element with the identifier "primaryDataSource" must appear in the document."
It definitely works. You can reference beans from one file to another. You need to use "ref bean" instead of "ref local" and I think you also need to give your beans ids instead of names.
I have given the beans ids and not names and the error i am getting is from the XML parser. Perhaps it is the opposite, that i should use names instead of id's? I guess we can try that
It definitely works with id's. None of my beans have names and I can reference them from one file to another.
Chris Harris
Carlisle, UK
what xml parser are you using?
I'm afraid I don't know. I imagine it's whatever comes with jboss. If you can tell me how to find out, I'll be happy to do that.
Chris Harris
Carlisle, UK
It sounds like something is set up wrong. If you're using "ref bean" then the XML content handler shouldn't even try to resolve those references -- it should be handled at the next level up, after all of the files have been parsed.