spring注解 实现一个接口多个实现类的区分

来源:互联网 发布:建站123 编辑:程序博客网 时间:2024/06/05 20:50

相应的包

import javax.annotation.Resource;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier;

方式一:@Resource(name="XXXX")

方式二:@Autowired    @Qualifier("XXXX")

示例如下:

@Service("ISchoolSerice")public class SchoolService implements ISchoolSerice{ @Resource(name="student2")private IStudentDao sd ;@Autowired@Qualifier("teacher")  //指定实现类private ITeacherDao td;}


 

阅读全文
1 0
原创粉丝点击