Error in Spring Project Execution

Asked

Viewed 1,325 times

1

I’m developing an application in Spring (from the Algaworks booklet) and came across the following error:

. ____ _ __ _ _ /\ / ' __ _ ()_ __ __ _ \ \ \ \ ( ( )_ | '_ | '| | ' / ` | \ \ \ \ / )| |)| | | | | || (| | ) ) ) ) ' |____| .|| ||| |, | / / / / =========||==============|/=///_/ :: Spring Boot : (v1.4.0.RELEASE)

2016-08-03 10:09:27.151 INFO 14480 --- [ restartedMain] b.p.f.festa.Gestaofestaapplication : Starting Gestaofestaapplication on Fagner-nbw01 with PID 14480 (D: Dev workspaces spring gestao-festa target classes Started by Fagner in D: Dev workspaces spring gestao-festa) 2016-08-03 10:09:27.156 INFO 14480 --- [ restartedMain] b.p.f.festa.Gestaofestaapplication : No active profile set, Falling back to default profiles: default 2016-08-03 10:09:27.717 INFO 14480 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.Embedded.Annotationconfigembeddedwebapplicationcontext@558b3a37: startup date [Wed Aug 03 10:09:27 GMT-03:00 2016]; root of context Hierarchy 2016-08-03 10:09:29.920 INFO 14480 --- [ restartedMain] s.b.c.e.t.Tomcatembeddedservletcontainer : Tomcat initialized with port(s): 8080 (http) 2016-08-03 10:09:29.943 INFO 14480 --- [ restartedMain] o.apache.Talina.core.Standardservice : Starting service tomcat 2016-08-03 10:09:29.944 INFO 14480 --- [ restartedMain] org.apache.Catalina.core.Standardengine : Starting Servlet Engine: Apache Tomcat/8.5.4 2016-08-03 10:09:30.149 INFO 14480 --- [Ost-startStop-1] o.a.c.C.[Tomcat]. [localhost]. [/] Initializing Spring Embedded Webapplicationcontext 2016-08-03 10:09:30.150 INFO 14480 --- [Ost-startStop-1] o.s.web.context.Contextloader : Root Webapplicationcontext: initialization completed in 2439 ms 2016-08-03 10:09:30.488 INFO 14480 --- [Ost-startStop-1] o.s.b.w.Servlet.Servletregistrationbean : Mapping Servlet: 'dispatcherServlet' to [/] 2016-08-03 10:09:30.494 INFO 14480 --- [Ost-startStop-1] o.s.b.w.Servlet.Filterregistrationbean : Mapping filter: 'characterEncodingFilter' to: [/] 2016-08-03 10:09:30.495 INFO 14480 --- [Ost-startStop-1] o.s.b.w.Servlet.Filterregistrationbean : Mapping filter: 'hiddenHttpMethodFilter' to: [/] 2016-08-03 10:09:30.495 INFO 14480 --- [Ost-startStop-1] o.s.b.w.Servlet.Filterregistrationbean : Mapping filter: 'httpPutFormContentFilter' to: [/] 2016-08-03 10:09:30.495 INFO 14480 --- [Ost-startStop-1] o.s.b.w.Servlet.Filterregistrationbean : Mapping filter: 'requestContextFilter' to: [/] 2016-08-03 10:09:30.571 WARN 14480 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered During context initialization - cancelling refresh Attempt: org.springframework.Beans.factory.Unsatisfieddependencyexception: Error Creating bean with name 'guest': Unsatisfied dependency Expressed through field 'guests': No Qualifying bean of type [br.pro.fagnerlima.repository.Guests] found for dependency [br.pro.fagnerlima.repository.Guests]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency Annotations: {@org.springframework.Beans.factory.Annotation.Autowired(required=true)}; nested Exception is org.springframework.Beans.factory.Nosuchbeandefinitionexception: No Qualifying bean of type [br.pro.fagnerlima.repository.Guests] found for dependency [br.pro.fagnerlima.repository.Guests]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency Annotations: {@org.springframework.Beans.factory.Annotation.Autowired(required=true)} 2016-08-03 10:09:30.575 INFO 14480 --- [ restartedMain] o.apache.Catalina.core.Standardservice : Stopping service Tomcat 2016-08-03 10:09:30.619 INFO 14480 --- [ restartedMain] utoConfigurationReportLoggingInitializer :

Error Starting Applicationcontext. To display the auto-Configuration report enable debug logging (start with --debug)

2016-08-03 10:09:30.655 ERROR 14480 --- [ restartedMain] o.s.boot.Springapplication : Application startup failed

org.springframework.Beans.factory.Unsatisfieddependencyexception: Error Creating bean with name 'guest': Unsatisfied dependency Expressed through field 'guests': No Qualifying bean of type [br.pro.fagnerlima.repository.Guests] found for dependency [br.pro.fagnerlima.repository.Guests]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency Annotations: {@org.springframework.Beans.factory.Annotation.Autowired(required=true)}; nested Exception is org.springframework.Beans.factory.Nosuchbeandefinitionexception: No Qualifying bean of type [br.pro.fagnerlima.repository.Guests] found for dependency [br.pro.fagnerlima.repository.Guests]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency Annotations: {@org.springframework.Beans.factory.Annotation.Autowired(required=true)} at org.springframework.Beans.factory.Annotation.Autowiredannotationbeanpostprocessor$Autowiredfieldelement.inject(Autowiredannotationbeanpostprocessor.java:569) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.Annotation.InjectionMetadata.inject(Injectionmetadata.java:88) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.Annotation.AutowiredAnnotationBeanPostProcessor.postPropertyValues(Autowiredannotationbeanpostprocessor.java:349) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(Abstractautowirecapablenfactory.java:1214) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(Abstractautowirecapablebeanfactory.java:543) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(Abstractautowirecapablenfactory.java:482) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:306) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(Defaultsingletonbeanregistry.java:230) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.AbstractBeanFactory.doGetBean(Abstractbeanfactory.java:302) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.AbstractBeanFactory.getBean(Abstractbeanfactory.java:197) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.Beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(Defaultlistablebeanfactory.java:776) ~[spring-Beans-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.context.support.Abstractapplicationcontext.finishBeanFactoryInitialization(Abstractapplicationcontext.java:861) ~[spring-context-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.context.support.Abstractapplicationcontext.refresh(Abstractapplicationcontext.java:541) ~[spring-context-4.3.2.RELEASE. jar:4.3.2.RELEASE] at org.springframework.boot.context.Embedded.EmbeddedWebApplicationContext.refresh(Embeddedwebapplicationcontext.java:122) ~[spring-boot-1.4.0.RELEASE. jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(Springapplication.java:759) [spring-boot-1.4.0.RELEASE. jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(Springapplication.java:369) [spring-boot-1.4.0.RELEASE. jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.run(Springapplication.java:313) [spring-boot-1.4.0.RELEASE. jar:1.4.0.RELEASE] at org.springframework.boot.SpringApplication.run(Springapplication.java:1185)

Repository on Github: https://github.com/fagnerlima91/primeiros-passos-com-spring

  • Try MOVE* the Gestaofestaapplication.java class that is in the br.pro.fagnerlima.festa package for br.pro.fagnerlima. Probably Springboot is only looking at the classes that are in the class package forward ... Your Repository ended up getting a directory above.

  • 1

    It worked! Thank you very much.

  • I’ll move my suggestion then to reply and you mark it as correct ok ?

  • I’ll do it, @wryel.

1 answer

0


Move the class Gestaofestaapplication.java that’s in the package br.pro.fagnerlima.festa for br.pro.fagnerlima. Probably Springboot is only looking at the classes that are in the class package forward ... Your Repository ended up getting a directory above.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.