Springboot Secret - quickly build micro-service system - Wang Fujiang

JavaConfig items:

spring IOC has a very central concept --Bean. By the Spring container is responsible for instantiating, assembly and management of the Bean. Bean XML is used to describe the most popular configurations. Spring can be read from any type of metadata XML configuration file and automatically converted into the corresponding Java code. Spring open java programming model has changed, Spring downloaded more than 100 million times, we can see how Spring has been prevalent. 


With the increasing development of Spring, a growing number of people have criticized Spring. "Spring project with a lot of rotten XML" is one of the most thwarting criticism. As Spring will almost all business class configuration XML file in the form of Bean, resulting in a large number of XML documents. Uses XML to configure Bean lost the compile-time type safety. A large number of XML configuration makes the whole project more complex. Rod Johnson also noticed this very serious problem.

As with the release of JAVA EE 5.0, which introduces a very important characteristic ------ Annotations (comments). Note the source code is a label, these labels may be processed in the source code by a compiler or layer to melt it into the class file. In later versions of JAVA EE 5, the comment has become a major configuration options. Spring use comments to describe compared with the use of XML, configuration because the benefits Bean class comment in a class source code, you can get the type of security check. It can be a good support reconstruction. 

JavaConfig is to use comments to describe the components Bean configuration. JavaConfig is a sub-project of the Spring, compared to Spring, it is still a very young project. The current version is 1.0 M2. Bean uses XML to configure the functions that can be implemented equally well achieved by JavaConfig.

1. Any tagged @Configuration Java class definitions are a class configuration JavaConfig

2. Any tagged @Bean method, as the return value are registered to a bean definition Spring IoC container, the method becomes the default name of the bean definition id.

3.java annotation java annotations

 

Guess you like

Origin www.cnblogs.com/kaixin110/p/11056488.html