注释类型 Repository


  • @Target(TYPE)
    @Retention(RUNTIME)
    @Documented
    @Component
    public @interface Repository
    Indicates that an annotated class is a "Repository", originally defined by Domain-Driven Design (Evans, 2003) as "a mechanism for encapsulating storage, retrieval, and search behavior which emulates a collection of objects".

    Teams implementing traditional Java EE patterns such as "Data Access Object" may also apply this stereotype to DAO classes, though care should be taken to understand the distinction between Data Access Object and DDD-style repositories before doing so. This annotation is a general-purpose stereotype and individual teams may narrow their semantics and use as appropriate.

    A class thus annotated is eligible for Spring DataAccessException translation when used in conjunction with a PersistenceExceptionTranslationPostProcessor. The annotated class is also clarified as to its role in the overall application architecture for the purpose of tooling, aspects, etc.

    As of Spring 2.5, this annotation also serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning.

    从以下版本开始:
    2.0
    作者:
    Rod Johnson, Juergen Hoeller
    另请参阅:
    Component, Service, DataAccessException, PersistenceExceptionTranslationPostProcessor
    • 可选元素概要

      可选元素 
      修饰符和类型可选元素说明
      Stringvalue
      The value may indicate a suggestion for a logical component name, to be turned into a Spring bean in case of an autodetected component.
    • 元素详细资料

      • value

        String value
        The value may indicate a suggestion for a logical component name, to be turned into a Spring bean in case of an autodetected component.
        返回:
        the suggested component name, if any (or empty String otherwise)
        默认值:
        ""