首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

Intellij IDEA 如何去掉 @Autowired 注入警告

问题 在Service层注入Mybatis的Mapper我们通常会使用@Autowired 自动注入 @Autowired private ProductMapper productMapper; 但是这样...当我们在Controller层注入Service时我们也经常直接在Filed上使用@Autowired 注解,这时候不显示红色警告,但是也显示Field injection is not recommended...) { this.productService = productService; } or private ProductService productService; @Autowired public...你只需要把@Autowired扔到变量之上就好了,不需要特殊的构造器或者set方法,依赖注入容器会提供你所需的依赖。...提供的注解 @RequiredArgsConstructor 来解决这两个问题(Lombok这个大家项目都会使用吧) @Service @Log4j2 @RequiredArgsConstructor(onConstructor

3.7K30
领券