在我们写controller或者Service层的时候,需要注入很多的mapper接口或者另外的service接口,这时候就会写很多的@AutoWired注解,代码看起来很乱
lombok提供了一个注解:

@RequiredArgsConstructor(onConstructor =@_(@Autowired))
写在类上可以代替@AutoWired注解,需要注意的是在注入时需要用final定义,或者使用@notnull注解

private final User u;

相关文章:

  • 2021-10-15
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2021-11-19
猜你喜欢
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案