我很快就会生气:) 我有一个基本的服务类看起来像
@Service
public class CategoryService {
@Autowired
@Qualifier("categoryDaoImp")
CategoryDaoImp categoryDaoImp;
@PostConstruct
public void asdasdas()
{
System.out.println("Yaratıldı");
}
public CategoryService()
{
System.out.println("Bla Bla");
}
}
这是My Exception ..
Error creating bean with name 'categoryService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.iu.eblood.daoImp.CategoryDaoImp com.iu.eblood.serviceImp.CategoryService.categoryDaoImp; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.iu.eblood.daoImp.CategoryDaoImp] 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=categoryDaoImp)}
我确定已经创建了CategoryDaoImp类。因为我在上下文和调试模式下看到了 <创建班级列表
org.springframework.context.annotation.internalConfigurationAnnotationProcessor,
org.springframework.context.annotation.internalAutowiredAnnotationProcessor,
org.springframework.context.annotation.internalRequiredAnnotationProcessor,
org.springframework.context.annotation.internalCommonAnnotationProcessor,
org.springframework.context.annotation.internalPersistenceAnnotationProcessor,
categorydaoimp,
categoryService,
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#0,
DB2DataSource
,sessionFactory,
hibernateTemplate,
org.springframework.aop.config.internalAutoProxyCreator,
org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,
org.springframework.transaction.interceptor.TransactionInterceptor#0,
org.springframework.transaction.config.internalTransactionAdvisor,
org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,
DB2TransactionManager
答案 0 :(得分:2)
查看bean名称和类型(CategoryDaoImp
)我想有一个CategoryDao
接口。试试这个:
@Autowired
CategoryDao categoryDao;
问题是@Transactional
注释(再次猜测)你放在CategoryDao
上。