-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Amit opened SPR-11382 and commented
I have the below code that worked with spring 3.2 and fails with a "NoSuchBeanDefinitionException" on spring 4.0.0.RELEASE
public interface Cacheable {
}
public class TimeUnit implements Cacheable {
}
@Component
public class UserDao<T extends Cacheable> {
public void performDBOperation() {
System.out.println("Executing db operation");
}
}
@Component
public class UserService {
@Autowired
private UserDao<TimeUnit> timeUnitUserDao;
public void someService() {
timeUnitUserDao.performDBOperation();
}
}
It fails due to generics when I include ```
public class UserDao<T extends Cacheable>
"NoSuchBeanDefinitionException: No qualifying bean of type [spring.generics.UserDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userdao)}"
If the declaration is just ```
public class UserDao<T>
```, it all works.
Any comments/inputs on what should be the fix?
Affects: 4.0 GA
Reference URL: http://stackoverflow.com/questions/21473926/upgrading-spring-from-3-2-to-4-issue-with-generics-extends
Issue Links:
- Problem with autowiring of "generic Beans" (defined via RootBeanDefinition(s)) [SPR-11250] #15875 Problem with autowiring of "generic Beans" (defined via RootBeanDefinition(s))
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug