SpringBoot Notes
SpringBoot Notes
SpringBoot Annotations
1)@SpringBootApplication - enables Spring Boot autoconfiguration and component
scanning.
2)@Bean - indicates that a method produces a bean to be managed by Spring.
3)@Service - indicates that an annotated class is a service class.
4)@Repository - indicates that an annotated class is a repository, which is an
abstraction of data access and storage.
5)@Configuration - indicates that a class is a configuration class that may contain
bean definitions.
6)@Controller - marks the class as web controller, capable of handling the
requests.
7)@RequestMapping - maps HTTP request with a path to a controller method.
8)@Autowired - marks a constructor, field, or setter method to be autowired by
Spring dependency injection.
9)@Component- is a generic stereotype for a Spring managed component. It turns the
class into a Spring bean at the auto-scan time. Classes decorated with this
annotation are considered as candidates for auto-detection when using annotation-
based configuration and classpath scanning.
10)@Repository, @Service, and @Controller are specializations of @Component for
more specific use cases.
11)@EnableAutoConfiguration (exclude ={classname})
12)@Controller- Map of the model object to view or template and make it
humanreadble
13)@Restcontroller- simply return the object and object data directly weitten in
http response as JSON or XML (@Controller+ @RsponseBody)
14)@ControllerAdvice- use for globale exception handling
15)@ExceptionHandler -use for exception handling massges for custome exceptions
16)@NotBlank - bean field is not empty. this is use for server side validation
using javax validation dependancy
Tip:-
There are also Hibernate @Entity, @Table, @Id, and @GeneratedValue annotations in
the example.
(*)Dependencies Injection:- it is smiler type of design pattern
loose cupling provide object without
directly
(*)IOC:- (Inversion of Control) Represent the inversion of responsibility of Object
creation, intitialization and destruction from application of Spring container