Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

[Bug] Field repository in br.com.alurafood.pagamentos.service.PagamentoService required a bean of type 'br.com.alurafood.pagamentos.repository.PagamentoRepositoy' that could not be found.

Importei o projeto da aula, mas apresenta esse erro ao executá-lo

Segue o erro:

16:26:21.216 [Thread-0] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@48509aa

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.7)

2023-03-17 16:26:21.579  INFO 15540 --- [  restartedMain] b.c.a.pagamentos.PagamentosApplication   : Starting PagamentosApplication using Java 19.0.2 on gws38-System-Product-Name with PID 15540 (/home/gws38/Downloads/2545-alurafood-ms-java-spring-aula_03/pagamentos/target/classes started by gws38 in /home/gws38/Downloads/2545-alurafood-ms-java-spring-aula_03/pagamentos)
2023-03-17 16:26:21.581  INFO 15540 --- [  restartedMain] b.c.a.pagamentos.PagamentosApplication   : No active profile set, falling back to 1 default profile: "default"
2023-03-17 16:26:21.649  INFO 15540 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-17 16:26:21.649  INFO 15540 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-17 16:26:22.722  INFO 15540 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2023-03-17 16:26:22.732  INFO 15540 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2023-03-17 16:26:22.732  INFO 15540 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.62]
2023-03-17 16:26:22.797  INFO 15540 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2023-03-17 16:26:22.797  INFO 15540 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1147 ms
2023-03-17 16:26:22.848  WARN 15540 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pagamentoController': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pagamentoService': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'br.com.alurafood.pagamentos.repository.PagamentoRepositoy' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2023-03-17 16:26:22.850  INFO 15540 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-03-17 16:26:22.870  INFO 15540 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-03-17 16:26:22.886 ERROR 15540 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field repository in br.com.alurafood.pagamentos.service.PagamentoService required a bean of type 'br.com.alurafood.pagamentos.repository.PagamentoRepositoy' 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 'br.com.alurafood.pagamentos.repository.PagamentoRepositoy' in your configuration.

1 resposta
solução!

Consegui resolver, apenas troquei @Autowired por @Autowired(required = false)

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software