Announcement Announcement Module
No announcement yet.
@Repository and <mongo:repositories base-package/> Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Repository and <mongo:repositories base-package/>

    Should I use @Repository on my beans inside mongo:repositories base-package?
    All of my repository beans extends MongoRepository, so they will be detected by mongo:repositories instruction, although I'm not sure about automatic exception translation (should I add @Repository for each of my repository bean), and will it work just with mongo:repositories? I use <context:component-scan base-package/> to activate @Repository lookup, but component-scan base-package is different from mongo:repositories base-package.

    So, summarize:
    1. will mongo:repositories handle nicely @Repository annotation on my MongoRepository beans?
    2. if yes, than will it provide automatic exception translation for my beans, or this is done by default, and I don't need @Repository at all.

  • #2
    You don't need @Repository. The exception translation is automatically applied on the MongoTemplate level so that the repositories benefit from it transparently.