码迷,mamicode.com
首页 > 其他好文 > 详细

为什么在Controller层中,自动注入Iservice,而不是serviceImpI?

时间:2019-11-05 15:05:16      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:art   博客   接口   代码   details   ice   auto   面向接口编程   ISE   

经常写的代码:@Autowrite Aservice  aservice

不明白为什么在注入的是抽象层,而不是实现层,直到看到了这篇博客:https://blog.csdn.net/qq_31963719/article/details/79458002

明白了什么是所谓的 面向接口编程

 

在自动注入抽象层的时候,会实例化该抽象类,而serviceImp是service的实现类,所以自动的生成这个实现类。

为什么在Controller层中,自动注入Iservice,而不是serviceImpI?

标签:art   博客   接口   代码   details   ice   auto   面向接口编程   ISE   

原文地址:https://www.cnblogs.com/zzw3014/p/11798360.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!