1. @Autowired:
Is a possible class member variables, methods, constructors are labeled, so that spring to apply automatic assembly work of bean object comment.
Matched according to the default class, to specify the name with @Qualifier assembly bean.
Objective: to eliminate the use of @Autowired set, get method.
ex:
//成员属性使用 -> 无需相应的 set 方法
@Autowired
private UserService userService;
//set 方法使用 @Autowired
private UserService userService;
@Autowired
public void setUserService (UserService userService) {
this.userService= userService;
}
//构造方法使用 @Autowired
private UserService userService ;
@Autowired
public UserController(UserService userService) {
this.userService = userService;
}
2.@Mapper
Identifying an interface layer, in order to reduce the complexity of service logic layer the pressure.
3.@Component
4.@SpringbootApplication:
Logo program entry notes.
5.@RestController :
Equivalent @Controller + @ResponseBody.
RESTFUL style => plus @RestController comment, indicating that this class returns the data directly written to the browser, but also json data , more conducive to front-end data processing, standardization of thought.
6.@RequestMapping(value = ‘xxx’ , method = RequestMethod.GET/POST)
/: Or representatives.
Used as a processing request annotation. E.g:
In addition there are similar:
@POSTMapping equivalent @RequestMapping (value = 'xxx', method = RequestMethod.POST)
@GETMapping 等同于 @RequestMapping(value = ‘xxx’ , method = RequestMethod.GET)
7.@Service
Notes identifies the service class.
8.@Configuration
9.@Bean
10. @ ControllerAdvice:
Gracefully handle the exception, with @ExceptionHandler use.
ex: a global catch exceptions:
11.@Slf4j & @Log4j2
lombok (configuration required) log management functions provided.
12.@CrossOrigin(origins = "*" , maxAge = 3600)
To solve the problem of cross-domain backend.