Repository annotation
@Repository is a Spring stereotype annotation that marks a class as a data-access component eligible for bean registration and persistence-exception translation.
Spring Start Here, Second Edition
The Spring @Repository stereotype annotation marks a class as a data-access component eligible for bean registration.
- How it is used
- Marks data-access classes for Spring bean registration while making their repository responsibility visible.
- How deep it goes
- Explains stereotype selection and bean registration, then demonstrates constructor injection into a repository.
- Examples
- Uses a comment repository implementation and a purchase repository that injects JdbcTemplate.
- What you can do after
- Apply it via Spring to register a repository class and make its data-access role clear.
Read how Spring Start Here, Second Edition explains repository annotation →
Java Persistence with Spring Data and Hibernate epub
The Spring Repository annotation identifies a component as a data-access repository and enables translation of persistence exceptions into Spring's unchecked data-access exceptions.
- How it is used
- Marks DAO classes as Spring components within a JPA persistence layer.
- How deep it goes
- Explains component registration and persistence-exception translation, then demonstrates application on concrete DAO implementations.
- Examples
- Uses ItemDaoImpl and BidDaoImpl as repository implementations backed by an injected EntityManager.
- What you can do after
- Configure DAO classes as Spring components with automatic persistence-exception translation.
Read how Java Persistence with Spring Data and Hibernate epub explains repository annotation →
Related concepts
- stereotype annotationkind of · A stereotype annotation marks a program element as belonging to a particular architectural or semantic role.
- data access objectconfigures · A data access object is a component that encapsulates operations for accessing and manipulating data in a persistent store.
- dependency graphpart of · A dependency graph is a graph whose nodes represent entities and whose edges represent dependency relationships among them.
Questions about repository annotation
What is repository annotation?
@Repository is a Spring stereotype annotation that marks a class as a data-access component eligible for bean registration and persistence-exception translation.
Which Manning books explain repository annotation?
Spring Start Here, Second Edition and Java Persistence with Spring Data and Hibernate epub.
What is repository annotation a kind of?
Repository annotation is a kind of stereotype annotation. A stereotype annotation marks a program element as belonging to a particular architectural or semantic role.
What is repository annotation part of?
Repository annotation is part of dependency graph. A dependency graph is a graph whose nodes represent entities and whose edges represent dependency relationships among them.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

