Bonjour,
J'obtiens la même erreure pour tout les tests:
1. En executant gradle bootRun :
Description: Field cs in com.yaps.petstore.api.CreateCustomerController required a bean of type 'com.yaps.petstore.domain.service.CustomerService' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action: Consider defining a bean of type 'com.yaps.petstore.domain.service.CustomerService' in your configuration.
2. En executant gradle myTest
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.yaps.petstore.domain.service.CustomerService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Mais je ne comprends pas bien que dois je faire...
Merci
No qualifying bean of type
Modérateurs : graffiop, jmdouin, agoncal, mlebihan
Re: No qualifying bean of type
1- Pour ton premier erreur : dans CreateCustomerController faut déclarer CustomerService en Autowired comme cela
@Autowired
CustomerService customerService ;
2- Pour deuxième erreur faut créer ta classe CustomerServiceImpl dans le package com.yaps.petstore.domain.service qui implémente CustomerService ( ne pas oublier l'annotation @Service )
@Service
public class CustomerServiceImpl implements CustomerService {
@Autowired
CustomerService customerService ;
2- Pour deuxième erreur faut créer ta classe CustomerServiceImpl dans le package com.yaps.petstore.domain.service qui implémente CustomerService ( ne pas oublier l'annotation @Service )
@Service
public class CustomerServiceImpl implements CustomerService {
Re: No qualifying bean of type
Merci beaucoup, le problème est que j'ai déjà ces deux annotations dans mon code et l'erreur persiste malgré ça.
Re: No qualifying bean of type
Est ce que t'as définit CustomerServiceImpl implémentant le CustomerService comme celà ?
package com.yaps.petstore.domain.service;
.....
@Service
public class CustomerServiceImpl implements CustomerService {
@Autowired
private CustomerRepository customerRepository;
package com.yaps.petstore.domain.service;
.....
@Service
public class CustomerServiceImpl implements CustomerService {
@Autowired
private CustomerRepository customerRepository;