I am deciding on a naming convention for my Spring application context files. I've come across this blog and a couple of tutorials suggesting applicationContext-<name>.xml
is the way to go. I'm generally not a find of mixing camel case with dashes/underscores. What are some other naming conventions have you seen?
Edit: I'm also thinking of nesting context files inside the package that pertains to them. For example, my classes/interfaces that relates to ordering would go in context file com/mycompany/order/spring-context.xml
. I would have a top-level applicationContext.xml
that pulls everything together. Suggestions?
I very much support the applicationContext-<name>.xml
convention.
In general <name>
refers to the Maven module name in all our projects. So, each module that requires a Spring configuration has its own applicationContext-<name>.xml
file. The "execution module" i.e. the one module that represents the sort of the entry point into the application (WAR, EAR, etc.) has a single applicationContext.xml
that only imports all the applicationContext-<name>.xml
files.
We use this convention company-wide strictly in all our Maven/Spring projects and it's proved to be extremely simple, clear and efficient.
If there were a convention, I would like it to be:
I tend to prefix my spring config files with "spring" makes it more obvious what they are used for, but this is not necessarily mandatory.
But let me say this would work for the way that I've dealt with my spring files, may not work for all contexts.
IMHO applicationContext-<name>.xml is a little verbose (long) and I like all lowercase as it's differentiates them from my java source and (I think) makes them easier to read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With