Erreur d'injection @Autowired
Bonjour je débutes avec Spring.
Après configuration j'ai cette erreur.
Code:
1 2
|
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'paysServices': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: better.dao.PaysDao better.services.PaysServices.paysDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [better.dao.PaysDao] 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)} |
Le code de ma Dao
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| @Repository
@Transactional(readOnly=true)
public class PaysDao extends AbstractJpaDAO<Pays> implements IPays{
private static final long serialVersionUID = 1L;
@PersistenceContext
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
@Override
protected Class<Pays> getEntityClass() {
return Pays.class;
}
@Override
public Collection<Pays> getAllPays(){
return super.findAll();
}
@Override
public Pays getPaysByCode(String code){
Map<String,Object> params=new HashMap<>();
params.put("code", code);
return super.findEntityByUsingQueryName(Pays.FIND_BY_CODE, params);
}
} |
Voici mon code de Service
Code:
1 2 3 4 5 6 7 8 9
|
@Service(value = "paysServices")
public class PaysServices implements GenericService<Pays> {
@Autowired
private PaysDao paysDao;
//setter
} |
Voici mon Controller
Code:
1 2 3 4 5 6
| @ManagedBean(name = "payscontroller")
@ViewScoped
public class PaysController implements Serializable {
@Autowired
private PaysServices paysServices;
} |