I have a test class that make me crazy with this error :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name .imprimirRelatorio: Unsatisfied dependency expressed through field repository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type v1.teste.Service available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
After search in the web by a resolution, I couldn't run the test. The test class was like that:
@RunWith(SpringJUnit4ClassRunner.class)
public class imprimirRelatorio {
@Autowired
PautaService pautaRepository;
@Test
public void imprimirCabecalho(){
PautaReportBuilder pautaReportBuilder = new PautaReportBuilder();
//Reuniao reuniao = reuniaoService.findOne(UUID.fromString("4c7d3fc8-f78d-4ed3-a1ad-83c5da822ea7"));
try {
pautaReportBuilder.cabecalhoRelatorios(reuniao);
} catch (Exception e)
{
e.printStackTrace();
}
}
}
/* Update */
So I forgot to say that I already tried the annotation @service in the pautaService interface. And the same on the test class I've tried to use the @SpringBootTest annotation. So the error messages was different.
The App.class
@SpringBootApplication
@ComponentScan({"br.com.empresa123.sistema123.*"})
public class App { public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
The interface PautaService:
@Service
public interface PautaService {
Page<Pauta> findAll(Pageable page);
Pauta findOne(UUID uuid);
Pauta save(Pauta pauta);
}
This is the first approach of my test , the nested exception were :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'subjectController': Unsatisfied dependency expressed through field 'subjectService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'subjectService': Unsatisfied dependency expressed through field 'domainSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dominio': Unsatisfied dependency expressed through field 'domainRepo'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'domainReposImpl': Unsatisfied dependency expressed through field 'sqlGenericPager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=sql-Generic-Pager)}
v1.teste.Service? I believe you'll get similar error when just starting an application. Share more code - itwasntme