Annotations - Spring Boot, Spring Cloud & Spring Framework
Spring Boot and Web annotations                                         Spring Cloud annotations                                           Spring Framework annotations
Use annotations to configure your web application.                      Make you application work well in the cloud.                       Spring uses dependency injection to configure and bind
                                                                                                                                           your application together.
T @SpringBootApplication - uses @Configuration,                          T @EnableConfigServer - turns your application into
@EnableAutoConfiguration and @ComponentScan.                            a server other apps can get their configuration from.               T @ComponentScan - make Spring scan the package
                                                                                                                                           for the @Configuration classes.
 T @EnableAutoConfiguration - make Spring guess the                     Use spring.application.cloud.config.uri in the client
configuration based on the classpath.                                   @SpringBootApplication to point to the config server.              T @Configuration - mark a class as a source of
                                                                                                                                           bean definitions.
 T @Controller - marks the class as web controller, capable             T @EnableEurekaServer - makes your app an Eureka
of handling the requests. T @RestController - a convenience             discovery service, other apps can locate services through it.      M @Bean - indicates that a method produces a bean to be
annotation of a @Controller and @ResponseBody.                                                                                             managed by the Spring container.
                                                                         T @EnableDiscoveryClient - makes your app register in the
M T @ResponseBody - makes Spring bind method’s return                   service discovery server and discover other services through it.    T @Component - turns the class into a Spring bean at the
value to the web response body.                                                                                                            auto-scan time. T @Service - specialization of the
                                                                        T @EnableCircuitBreaker - configures Hystrix circuit               @Component, has no encapsulated state.
M @RequestMapping - specify on the method in the                        breaker protocols.
controller, to map a HTTP request to the URL to this method.                                                                               C F M @Autowired - Spring’s dependency injection wires
                                                                        M @HystrixCommand(fallbackMethod =                                 an appropriate bean into the marked class member.
P @RequestParam - bind HTTP parameters into                             “fallbackMethodName”) - marks methods to fall back
method arguments.                                                       to another method if they cannot succeed normally.                 T M @Lazy - makes @Bean or @Component be initialized
                                                                                                                                           on demand rather than eagerly.
 P @PathVariable - binds placeholder from the URI
to the method parameter.                                                                                                                   C F M @Qualifier - filters what beans should be used to
                                                          HTTP Requests
                                                                                                                                           @Autowire a field or parameter.
                                @SpringBootApplication                                                        Cloud
    provides                                                                                                                                C F M @Value - indicates a default value expression for
      beans     like these                                                                                                                 the field or parameter, typically something like
                                                                                           asks
                                                                                                                                           “#{systemProperties.myProp}”
                                                                                       configuration       Configuration
   @Configuration                                     @RestController                                         server
                                                                                          receives                                          C F M @Required - fail the configuration,
                              @Service                                                   properties                                        if the dependency cannot be injected.
   @Bean                                             @Autowired
   public MyBean                                     Service service;
   provideBean()
                             @Component    beans
                                                                                       registers itself
                                                                                        as a service
                                                                                                                                           Legend
                                             are     @RequestMapping                                         Service
                                          injected   public Map serveRequest()                              discovery                      T - class
                                                                                       asks services
                                                                                         location                                          F - field annotation
                                                                                                                                           C - constructor annotation
                                                                                       receives URL
                                                                                                                                           M - method
                                                         HTTP Responses                                                                    P - parameter