tags:

views:

555

answers:

2

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?

+2  A: 

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.

cretzel
+1  A: 

In general, you should try to use id instead of name when you can. That way, the parser can catch duplicates for you.

lowellk