spring注解注入泛型子类
2015-07-17 11:34
381 查看
spring注解注入泛型子类
关于spring如何注入泛型实现类以下是项目的工程图
dao和service都使用了泛型设计
泛型dao接口
Java code
1 | public interface BaseDao<T, PK extends Serializable>{ |
Java code
1 | public class BaseDaoImpl<T, PK extends Serializable>implements BaseDao<T, PK> { |
Java code
1 | public interface StudentDao extends BaseDao<Student, Integer> { |
Java code
1 2 | @Repository public class StudentDaoImpl extends BaseDaoImpl<Student, Integer> implements StudentDao { |
Caused by: org.springframework.beans.factory. NoUniqueBeanDefinitionException: No qualifying bean of type [cn.ssh.annotation.dao.BaseDao] is defined: expected single matching bean but found 4: baseDaoImpl,studentDaoImpl,teacherDaoImpl,studentServiceImpl
1 | ApplicationContext context = new ClassPathXmlApplicationContext( "applicationContext.xml" ); |
2 | StudentDao studentDaoImpl = (StudentDaoImpl) context.getBean( "studentDaoImpl" ) |
1 | @Repository ( "baseDao" ) |
2 | public class BaseDaoImpl<T, PK extends Serializable> implements BaseDao<T, PK> { |
1 | public abstract class BaseDaoImpl<T, PK extends Serializable> implements BaseDao<T, PK> { |
相关文章推荐
- spring泛型注入的问题
- JAVA 获取系统路径
- SpringMVC 添加字段校验(注解的方式)
- Java Synchronized Blocks
- JAVA_SE基础——14.循环结构语句
- [LeetCode][Java] Add Binary
- java之IO处理
- SpringMVC框架介绍
- Java中有关Null的9件事
- Eclipse搭建SSH
- Eclipse快捷键
- JAVA去掉字符串中的各种奇怪字符
- [LeetCode][Java] Plus One
- Struts+Spring+Hibernate整合
- java Json对象解析
- Spring AOP之Advice
- java中System,Date学习笔记
- java实现基于SMTP发送邮件的方法
- Spring之构造注入与设值注入
- JAVA面试题:69道Spring面试题和答案