@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Component public @interface Repository
「データアクセスオブジェクト」などの従来の Java EE パターンを実装するチームもこのステレオタイプを DAO クラスに適用できますが、データアクセスオブジェクトと DDD スタイルのリポジトリの違いを理解してから行う必要があります。このアノテーションは汎用のステレオタイプであり、個々のチームはセマンティクスを絞り込み、必要に応じて使用できます。
このようにアノテーションが付けられたクラスは、PersistenceExceptionTranslationPostProcessor
と組み合わせて使用されると、Spring DataAccessException
変換の対象になります。アノテーション付きクラスは、ツールやアスペクトなどの目的で、アプリケーションアーキテクチャ全体におけるそのロールについても明確化されています。
Spring 2.5 以降、このアノテーションは @Component
の特殊化としても機能し、実装クラスをクラスパススキャンによって自動検出できるようにします。
Component
, Service
, DataAccessException
, PersistenceExceptionTranslationPostProcessor
修飾子と型 | オプションの要素と説明 |
---|---|
java.lang.String | value この値は、自動検出されたコンポーネントの場合、Spring Bean に変換される論理コンポーネント名の提案を示している場合があります。 |
@AliasFor(annotation=Component.class) public abstract java.lang.String value