实操部分
- 需要lombok依赖
- 在对应需要注入属性的类上添加注解
@RequiredArgsConstructor
- 所有需要注入的属性改为final修饰
为什么
- lombok的@RequiredArgsConstructor会生成一个有参(所有的用final修饰的属性)构造器
- spring的自动注入会直接根据有参构造器进行注入
- SpringBoot Autowired 属性springboot autowired属性 autowired属性idea autowired属性 方法setter transactional springboot autowired项目 springboot candidates autowired matching springframework springboot annotation autowired springboot autowired nullpoint单元 invocationhandler springboot autowired springboot autowired resource 注解springboot autowired项目