我正在使用spring开发一个程序,并且我正面临这个问题,它说:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [com.owlexa.cms.dao.MemberProductDao]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
在我的观察中,问题在于我的服务/服务impl这里的细节
服务:
public interface MemberService {
Member findMemberByPK(Integer id);
void deleteMember(Member obj);
void saveOrUpdateMember(Member obj);
Page<Member> findMemberListing(MemberSearchParams params, Pageable pageable);
Member findMemberByColsAndValues(String[] cols, Object[] values);
/*MemberProduct*/
Page<MemberProduct> findMemberProductListing(MemberProductSearchParams params, Pageable pageable);
MemberProduct findMemberProductByColsAndValues(String[] cols, Object[] values);
}
和我的ServiceImpl
@Service
@Transactional(readOnly = true)
public class MemberServiceImpl implements MemberService{
@Autowired
MemberDao memberDao;
@Autowired
MemberProductDao memberProductDao;
MemberSearchParams memberParams = null;
MemberProductSearchParams memberProductParams = null;
@Override
public Member findMemberByPK(Integer id) {
return memberDao.findOne(id);
}
@Override
@Transactional
public void deleteMember(Member obj) {
memberDao.delete(obj);
}
@Override
@Transactional
public void saveOrUpdateMember(Member obj) {
memberDao.save(obj);
}
@Override
public Page<Member> findMemberListing(MemberSearchParams params, Pageable pageable) {
return memberDao.findListing(params, pageable);
}
public Member findMemberByColsAndValues(String[] cols, Object[] values) {
memberParams = new MemberSearchParams();
memberParams.setEqColumns(cols);
memberParams.setEqValues(values);
Page<Member> member = memberDao.findListing(memberParams, null);
if(member != null && !member.getContent().isEmpty()){
return member.getContent().get(0);
}
return null;
}
@Override
public Page<MemberProduct> findMemberProductListing(MemberProductSearchParams params, Pageable pageable) {
return memberProductDao.findListing(params, pageable);
}
@Override
public MemberProduct findMemberProductByColsAndValues(String[] cols, Object[] values) {
memberParams = new MemberSearchParams();
memberParams.setEqColumns(cols);
memberParams.setEqValues(values);
Page<MemberProduct> memberProduct = memberProductDao.findListing(memberProductParams, null);
if(memberProduct != null && !memberProduct.getContent().isEmpty()){
return memberProduct.getContent().get(0);
}
return null;
}
}
帮助我解决问题,请提供您的解决方案, thx提前。
答案 0 :(得分:0)
我相信会员产品DAO中至少有一个Autowired字段不是由Spring产生的。请分享您的MemberProductDAO文件以及您的Spring.xml文件以进行更多调试。