Error creating bean with name ‘XXXX’
The complete errors are as follows: Cause Analysis:
The complete error report is as follows:
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'testHelloController': Unsatisfied dependency expressed through field 'testHelloService'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
'com.jun.service.test.TestHelloService' available: expected at least 1 bean which qualifies as autowire
candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
Cause analysis:
Because I’m a beginner of springboot, I just want to let the project run first to see the effect. If it takes half a day to build the project structure completely, I will report such a mistake as soon as I start it. The reason is very clear, that is, I can’t find the testhelloservice object template to inject it when I start it, and then I look at the @ service annotation in the service layer. It’s very smart When spring boot is started, it does not scan the service layer. After looking at the data, if so, you can directly type a annotation @ componentscan in the application of spring boot startup class to solve this problem:
the following is the code before error reporting:
package com.jun.web.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
}
Code after error reporting:
package com.jun.web.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
**@ComponentScan(basePackages = {"com.jun.core.*","com.jun.service.*","com.jun.web.*"})**
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
}
Read More:
- Error creating bean with name usercontroller appears when springboot starts
- Spring AOP is an error creating bean with name
- Idea SpringBoot:Error creating bean with name ‘XXXXController‘
- Springboot startup exception: error creating bean with name ‘permissioncontroller’
- Zeppelin starts successfully, but an error is reported
- Zeppelin starts successfully, but an error is reported
- zookeeper_ An error is reported when the exporter starts
- Exception record. When eclipse starts, an error is reported when workspace is opened
- Springboot error creating bean with name ‘xmlmodelplug’:
- When centos7 uses the man search command, an error is reported no manual entry for XXXX
- Error creating bean with name ‘datasource’ defined in class path resource
- Error creating bean with name ‘requestMappingHandlerAdapter‘ defined in class path resource
- [Tomcat] an error is reported when Tomcat starts ERROR:transport error 202:bind failed:Address already
- The springboot test class reported an error NullPointerException
- org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
- When angular4.0 starts the project, an error is reported: the “@ angular / compiler cli” package was not properly installed
- Error creating bean with name ‘application‘: Instantiation of bean failed;
- Error creating bean with name ‘feignTargeter‘ defined in class path resource [org/springframework/cl
- Error creating bean with name ‘org.springframework.security.oauth2.config.annotation.web.configurati
- Error creating bean with name ‘helloController‘: Injection of autowired dependencies failed;