0

Spring 3.2 で動作し、Spring 4.0.0.RELEASE で「NoSuchBeanDefinitionException」で失敗する以下のコードがあります。

    
    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();
         }
    }



UserDao クラス宣言に T extends Cacheable を含めると、ジェネリックが原因で失敗します。完全な例外は

「NoSuchBeanDefinitionException: タイプ [spring.generics.UserDao] の適格な Bean が依存関係で見つかりませんでした: この依存関係のオートワイヤー候補として適格な少なくとも 1 つの Bean が必要です。依存関係の注釈: {@org.springframework.beans.factory.annotation.Autowired( required=true), @org.springframework.beans.factory.annotation.Qualifier(value=userdao)}"

宣言が UserDao < T > だけの場合、すべて機能します。

何を修正すべきかについてのコメント/入力はありますか?

4

1 に答える 1