I've stumbled upon a rather strange issue today with Spring 3.0:
There's an abstract class A
and its concrete implementation A_Impl
. A_Impl
is annotated as @Repository
and is auto-scanned by Spring (<context:component-scan>
and <context:annotation-config/>
are both declared in context). A
and A_Impl
are deployed in separate JARs (not sure if that matters). Everything works just fine.
Now, I was reviewing that code and @Repository
didn't seem like a good fit semantically (the class in question has nothing to do with persistence) so - in my infinite wisdom - I've decided to change that to more generic @Component
. Needless to say, everything blew up leaving me looking like a complete idiot. The error (which occurred during Spring context initialization) was Spring's ClassPathResource.getInputStream()
method complaining about A
class not being there (it is, I've manually checked; plus regular class loader finds it just fine)
Nothing else has changed. If I swap @Component
for @Repository
context initializes, if I swap them back it doesn't with the above error. Spring documentation claims there's no difference between @Component
and @Repository
which is clearly a damned lie :-) So I wonder - what is the difference?