I use spring boot 3.3.2 and lombok. No issue to run application
When i run this test, I get an error
Error creating bean with name ‘manageEditorApplicationService’:
Unsatisfied dependency expressed through constructor parameter 0:
Error creating bean with name ‘manageEditorBusinessService’:
Unsatisfied dependency expressed through constructor parameter 0: No
qualifying bean of type
‘com.acme.querylog.repository.QueryLogRepository’
I use @Service, @Repository and @RequiredArgsConstructor, so bean should be know
@SpringBootTest(classes = {ManageEditorApplicationService.class,
ManageEditorBusinessService.class})
class ManageEditorApplicationServiceTest {
@Autowired
private ManageEditorApplicationService manageEditorApplicationService;
@Test
void validateMandatoryData_Test() {
ChoiceSliceEnum choiceSliceEnum = ChoiceSliceEnum.TEN;
ChoiceSliceProcessEnum choiceSliceProcessEnum = ChoiceSliceEnum.ZERO;
boolean isValid = manageEditorApplicationService.validateMandatoryData(choiceSliceEnum, choiceSliceProcessEnum);
assertFalse(isValid);
}
}
My code
@Service
@RequiredArgsConstructor
@Slf4j
public class ManageEditorApplicationService {
private final ManageEditorBusinessService manageEditorBusinessService;
public boolean validateMandatoryData(ChoiceSliceEnum choiceSliceEnum, ChoiceSliceProcessEnum choiceSliceProcessEnum) {
return valid=true;
}
...
}
@Service
@RequiredArgsConstructor
@Slf4j
public class ManageBusinessService {
private final QueryLogRepository requeteRepository;
...
}
@Repository
@Transactional(readOnly = true)
public interface QueryLogRepository extends JpaRepository<QueryLog, Long>, JpaSpecificationExecutor<QueryLog> {
}