Spring Boot and Web Annotations provide essential tools for configuring web applications with Spring. Key annotations include @SpringBootApplication for configuration, @Controller and @RestController for handling web requests, @RequestMapping and @PathVariable for mapping requests to controller methods, and @ComponentScan for auto-scanning. Spring Framework Annotations focus on dependency injection and configuration, such as @Autowired for wiring application parts together, @Bean and @Configuration for defining beans, and @Import and @DependsOn for loading additional configuration and controlling bean initialization order.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
532 views1 page
Cheatsheet Jrebel Spring Annotations
Spring Boot and Web Annotations provide essential tools for configuring web applications with Spring. Key annotations include @SpringBootApplication for configuration, @Controller and @RestController for handling web requests, @RequestMapping and @PathVariable for mapping requests to controller methods, and @ComponentScan for auto-scanning. Spring Framework Annotations focus on dependency injection and configuration, such as @Autowired for wiring application parts together, @Bean and @Configuration for defining beans, and @Import and @DependsOn for loading additional configuration and controlling bean initialization order.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Annotations Cheat Sheet
Spring Boot and Web Annotations Spring Framework Annotations
Use annotations to configure your web application. Spring uses dependancy injection to configure and bind your T M @Primary - gives higher preference to a bean appliation together. when there are multiple beans of the same type. T @SpringBootApplication - uses @Configuration, @EnableAutoConfiguration and @ComponentScan. T @Configuration - used to mark a class as a source of C F M @Required - shows that the setter method the bean definitions. must be configured to be dependency-injected with a T @EnableAutoConfiguration - make Spring guess the value at configuration time. configuration based on the classpath. T @ComponentScan - makes Spring scan the packages configured with it for the @Configuration classes. C F M @Value - used to assign values into fields in T @Controller - marks the class as web controller, Spring-managed beans. It’s compatible with the capable of handling the requests. T @Import - loads additional configuration. This one constructor, setter, and field injection. works even when you specify the beans in an XML file. T @RestController - a convenience annotation of a T M @DependsOn - makes Spring initialize other @Controller and @ResponseBody. T @Component - turns the class into a Spring bean at beans before the annotated one. the auto-scan time. M T @ResponseBody - makes Spring bind method's T M @Lazy - makes beans to initialize lazily. @Lazy return value to the web response body. T @Service - tells Spring that it's safe to manage annotation may be used on any class directly or indirectly @Components with more freedom than regular M @RequestMapping - specify on the method in the annotated with @Component or on methods annotated components. controller, to map a HTTP request to the URL to this method. with @Bean. C F M @Autowired - wires the application parts P @RequestParam - bind HTTP parameters into T M @Scope - used to define the scope of a @Com- together, on the fields, constructors, or methods in method arguments. ponent class or a @Bean definition and can be either a component. singleton, prototype, request, session, globalSession, or P @PathVariable - binds placeholder from the URI to custom scope. M @Bean - specifies a returned bean to be managed by the method parameter. Spring context. The returned bean has the same name as T @Profile - adds beans to the application only when the factory method. that profile is active. M @Lookup - tells Spring to return an instance of the method’s return type when we invoke it.
Legend: T - Class F - Field Annotation C - Constructor Annotation M - Method P - Parameter