Spring Cloud Common Annotations

@SpringBootApplication (exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) 
Overview: @SpringBootApplication = (default property) @Configuration + @EnableAutoConfiguration + @ComponentScan, @ ComponentScan basePackages, includeFilters, excludeFilters properties automatically determined dynamic range scan, the type of scan types has not, by default: it scans all types, and the scan range is a class-based configuration packets and sub-packets @ComponentScan annotation resides.
Reference: https://www.cnblogs.com/MaxElephant/p/8108140.html ; https://www.jianshu.com/p/39ee4f98575c

@EnableEurekaClient
Overview: If the registry is chosen eureka, then it is recommended @EnableEurekaClient, if other registries, it is recommended to use @EnableDiscoveryClient. 
Reference: https://www.jianshu.com/p/f6db3117864f

@FeignClient (name = "bigdataservice") 
Overview: FeignClient simplifies the writing of the request, and choose which service to use for consumption, and all this is achieved by dynamically configured by Spring dynamic load, we do not care about these, just use that is can. Besides, is to simplify the writing, RestTemplate need to write the server IP information, etc., and FeignClient does not.
Reference: https://blog.csdn.net/github_39577257/article/details/81842234 ; https://blog.csdn.net/ZYC88888/article/details/81291684

@RestController 
Overview: The equivalent of two annotated @ Controller + @ ResponseBody, return json data does not need to add @ResponseBody notes in the previous method, but using @RestController this annotation, you can not return to jsp, html pages, view resolver can not resolve jsp, html page.
Reference: https://www.cnblogs.com/shuaifing/p/8119664.html ; https://blog.csdn.net/qq_41063141/article/details/81805082

@RequestMapping ( "/ fei") 
Overview: @RequestMapping mapping request path, if the label on a class of a controller, indicates that the method of access paths should be added such that the path configuration; the most common are marked in the method, which indicate specific ways to deal with a particular request is accepted.
Reference: https://blog.csdn.net/yiye2017zhangmu/article/details/80500932 ; https://blog.csdn.net/jeofey/article/details/76019953 ; https://www.oschina.net/translate/ using-the-spring-requestmapping- annotation

@GetMapping ( "/ cf")
Overview: @GetMapping annotation is a combination, it is an abbreviation @RequestMapping (method = RequestMethod.GET), which maps HTTP Get annotation to a specific treatment method.
Reference: https://www.cnblogs.com/niexinlei/p/9704075.html ; https://blog.csdn.net/weixin_38553453/article/details/73692863

@Getter 
annotation on the class, the class to provide read-write property
Reference: https://blog.csdn.net/qq_37433657/article/details/83275051
@Setter 
annotation on the class, the class to provide read-write property
Reference: https://blog.csdn.net/qq_37433657/article/details/83275051
@ToString 
annotation on the class, the class provides toString () method
Reference: https://blog.csdn.net/qq_37433657/article/details/83275051
@ExcelTitle ( "Asset Number")
@Documented // document 
@Retention (RetentionPolicy.RUNTIME) // can be acquired at runtime
@Target ({ElementType.TYPE, ElementType.FIELD}) // applied to classes, methods, interfaces fine
@Inherited // subclasses inherit
@Data 
annotation on the class to provide read-write property class, in addition to providing a equals (), hashCode (), toString () Method
Reference: https://blog.csdn.net/qq_37433657/article/details/83275051
@Resource 
default assembly by name, the name can not be found when matching the type of bean will be assembled by
Reference: https://blog.csdn.net/qq_16055765/article/details/78833260
 
@Component 
refers to the components when the components are classified bad, we can use this annotation to mark
Reference: https://blog.csdn.net/qq_16055765/article/details/78833260
 
@Validated 
used in type, and a method parameter. But not for the member properties (field)
Reference: https://blog.csdn.net/weixin_38118016/article/details/80977207 ; https://blog.csdn.net/herojuice/article/details/86020101

@Valid 
for verifying compliance with requirement annotations can be used in the methods, constructors, methods, parameters and member attributes (field) on
reference: https://blog.csdn.net/weixin_38118016/article/details/80977207 ; HTTPS: / /blog.csdn.net/herojuice/article/details/86020101
 
@EnableFeignClients 
enable feign client

@EnableRedisHttpSession

@Bean 
annotated with class represents the class @Configuration Spring IoC container may be used as a source bean definition. @Bean annotation tells Spring, with a @Bean annotation method returns an object that should be registered as a bean in the Spring application context.
Reference: https://www.cnblogs.com/microcat/p/7074720.html
@Primary 
when multiple candidates when Bean automatic assembly, is annotated as @Primary Bean will serve as the first choice for those who would otherwise throw an exception
Reference: https://blog.csdn.net/qq_16055765/article/details/78833260
 
@ConditionalOnMissingBean(ObjectMapper.class)
 
@Service 
@Service label for the business layer components, @ Controller for controlling annotation layer assembly (e.g., the action struts), @ Repository for annotation data access components, i.e. DAO components, and refers @Component assembly, when the assembly is not good classification, we can use this annotation to mark.
@Autowired 
can annotate class member variables, methods and constructors, the completion of the automatic assembly. By using @Autowired to eliminate set, get method.

@Override 
when onCreate override the parent class, in front of the method plus @Override system can help you check the correctness of the method.

@Repository 
@Service label for the business layer components, @ Controller for controlling annotation layer assembly (e.g., the action struts), @ Repository for annotation data access components, i.e. DAO components, and refers @Component assembly, when the assembly is not good classification, we can use this annotation to mark.

@Query (value = "AVG (cost ) cost, SUM (totla_original_value) original, AVG (aera) aeara, STATISTICS_MONTH month from stat_finance where STATISTICS_YEAR =? 1 and department =? 2 group by STATISTICS_MONTH", nativeQuery = true) 
To simplify Dao the code used to write JPA Dao, using methods Dao @Query annotation interface does not need to write an implementation class (Impl).
 

With  @Configuration  annotation class indicates that the class can be used as a source Spring IoC container bean definition. @Bean  annotation tells Spring, with a @Bean annotation method returns an object that should be registered as a bean in the Spring application context.

Guess you like

Origin www.cnblogs.com/ratels/p/11121385.html