I have a repository class as below, and i wonder whether the stereotype name is important ? as i put any name to replace "userRepository", it still running fine, could someone please enlighten me ?
It comes into play when multiple beans of same type are instantiated.
Spring's default behaviour is type based autowiring. When it sees @Autowired, it just looks for the bean class that matches that type and has same class name as the field name.
If you create a second UserRepository implementation and it too is annotated with @Repository, it'll get instantiated but wiring will fail with an exception on the lines of "expected single match but found 2".
You'll have to then explicitly tell Spring which one of them to wire by adding @Qualifier("name") alongside @Autowired.
Paper jam tastes about as you would expect. Try some on this tiny ad:
a bit of art, as a gift, the permaculture playing cards