Spring通过注解自动扫描Service,无需xxxServiceImpl
cshyz opened this issue · 4 comments
cshyz commented
兄弟已经在spring-service.xml中配置了:
<context:component-scan base-package="xxx.xxx.xxx.service" />
spring会自动扫描xxx.xxx.xxx.service包下所有注解,完成Bean的装配。
可直接在Service中写业务,无需xxxServiceImpl这一层。
liyifeng1994 commented
接口与实现分离
cshyz commented
这样的分离是有特别的用意么?
liyifeng1994 commented
1.定义接口时无需关心具体的实现
2.便于维护
3.形成了一种规范,大家都这么写
cshyz commented
受教