In a spring configuration, what is the difference between using name vs id?
-
03-07-2019 - |
Question
In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribute?
Solution
Essentially, this is really just a XML matter. But you can also use the name attribute to specify aliases for a bean using characters which would be illegal in an id, I think.
OTHER TIPS
In general, you should try to use id instead of name when you can. That way, the parser can catch duplicates for you.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow