spring springboot springcloud common comment

[Spring]
@Qualifier
in the Controller need to inject this server service then I realize there are two classes on how to distinguish these two impl it?
Qualifier means that those who pass through this label, which indicates that the implementation class is what we need, add @Qualifier annotation, note that the parameter names @Qualifier of one of the names defined @Service comment for us before.
When using @resource injected relatively simple annotations comes with a "name" of @Service val is one of the names annotations.
https://blog.csdn.net/qq_36567005/article/details/80611139

@Component most common components, may be injected into the spring containers management, if you want to use a custom assembly annotation
@Repository acting persistence
@Service acting on the business logic
@Controller applied to the presentation layer (spring-mvc annotations)
https://blog.csdn.net/fansili/article/details/78740877

@Bean

Annotations on the method returns an instance, if the name is not specified by the bean @Bean, the default is the same as the method name label;
@Resource
role: to assemble bean, can be written on the field or setter methods. Default by name by injection assembly, in accordance with the type of injection assembly name can not be found.
https://blog.csdn.net/yuyeqianhen/article/details/90177597

@Component acting class, @ Bean acting method.
@Component and @Bean are used and fitted into the register Bean Spring container, but more customizable Bean Component ratio. Component can achieve some fail to realize custom load classes.
https://blog.csdn.net/weixin_42493179/article/details/86584341

@Documented
element annotation marks, Javadoc tool will mark this annotation annotation information element is included in the javadoc.
==============
combination comment

[Notes] springboot
@ConfigurationProperties batch injection property profile
@Value a one injection
https://blog.csdn.net/clmmei_123/article/details/81871836

@EnableAutoConfiguration
autoloading find all the classpath Spring Boot Bean-- depending on the desired application.
Search all the META-INF / spring.factories configuration file from the classpath Thereafter, wherein org.springframework.boot.autoconfigure.EnableAutoConfiguration key corresponding configuration item to the spring containers
only spring.boot.enableautoconfiguration true (the default is true), when they come to enable automatic configuration
https://blog.csdn.net/l18848956739/article/details/100692163

Spring also had a loading mechanism similar to the Java SPI. It is configured in the name of the interface implementation class META-INF / spring.factories file, then the program reads the configuration file and instantiated. This custom SPI mechanism is the basis for Spring Boot Starter achieve.
https://blog.csdn.net/lldouble/article/details/80690446

@EnableTransactionManagement
use annotation @EnableTransactionManagement management of the affairs of Spring Boot

 

RefreshScope (org.springframework.cloud.context.scope.refresh) is a special spring cloud achieved scope provided for realizing the configuration, examples of the thermal load.
https://www.jianshu.com/p/188013dd3d02
required heat load of the bean need to add @RefreshScope annotation can be done to refresh the bean-related properties without restarting the application when configuration changes occur.
https://blog.csdn.net/weixin_40318210/article/details/87954179

 

@Configuration

Used to define the configuration class, alternative xml configuration file, the internal class annotated with one or more methods are annotated @Bean, these methods will be carried out or AnnotationConfigWebApplicationContext AnnotationConfigApplicationContext scan type, and used to construct bean definitions, initialization Spring container.

@ConditionalOnProperty

Acting on the class
https://www.cnblogs.com/duanxz/p/7493276.html

@Configuation equivalent to <Beans> </ Beans>
@Bean equivalent to <Bean> </ Bean>
@ComponentScan equivalent to the <context: Component Base-Package-Scan = "com.dxz.demo" />
HTTPS: //blog.csdn.net/BinshaoNo_1/article/details/85005935

@Configuration comment on the nature or @Component
Although Component annotation will be configured as a class, but did not, and so when generating object calls Car Driver car when generating proxy objects generated for CGLIB Class () method to perform two new operations so are different objects. At that time when Configuration Notes, a subclass of Class current object, and the method of interception, the second call car () method to obtain directly from the object into the BeanFactory, so get to the same object.
Original link: https: //blog.csdn.net/long476964/article/details/80626930

Summarized in one sentence @Configuration in all methods will be annotated with @Bean dynamic proxy, this method returns are the same instance is called.
https://blog.csdn.net/isea533/article/details/78072133

@ConditionalOnProperty
may be determined whether the configuration attribute value is injected through the configuration file
in the spring boot is sometimes necessary to control the configuration class is in effect, may be used to control @Configuration @ConditionalOnProperty annotation is in effect.

==============

[Notes] springcloud

@EnableDiscoveryClient and @EnableEurekaClient
thing in common: both can make registry to discover, scan-to-change service.
Different points: @EnableEurekaClient only applies to Eureka as a registration center, @ EnableDiscoveryClient may be other registries.
https://blog.csdn.net/zheng199172/article/details/82466139

Released 1595 original articles · won praise 1142 · Views 12,030,000 +

Guess you like

Origin blog.csdn.net/21aspnet/article/details/104042826