org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'xxx' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
问题:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.jeecgframework.web.system.service.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
No qualifying bean of type 'org.jeecgframework.web.system.service.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
配置:
spring-mvc-crm.xml
<context:component-scan base-package="com.jeecg.crm" >
spring-mvc-aop.xml
<context:component-scan base-package="org.jeecgframework.core.interceptors" />
spring-mvc-context.xml
<context:component-scan base-package="org.jeecgframework.core.aop" />
spring-mvc-hibernate.xml (7 matches)
<context:component-scan base-package="org.jeecgframework.easypoi." />
<context:component-scan base-package="org.jeecgframework.core.common.dao." />
<context:component-scan base-package="org.jeecgframework.core.common.service." />
<context:component-scan base-package="org.jeecgframework.jwt.service."/>
<context:component-scan base-package="com.jeecg.">
<context:component-scan base-package="org.jeecgframework.web.">
<context:component-scan base-package="com.zgg.">
spring-mvc-timeTask.xml
<context:component-scan base-package="org.jeecgframework.core.timer" />
spring-mvc.xml (2 matches)
<context:component-scan base-package="org.jeecgframework.web.,com.jeecg.,org.jeecgframework.jwt.,com.jeecg.crm.controller.,com.zgg.">
<context:component-scan base-package="springfox"/>
spring-mvc-crm.xml
<context:component-scan base-package="com.jeecg.crm" >
spring-mvc-aop.xml
<context:component-scan base-package="org.jeecgframework.core.interceptors" />
spring-mvc-context.xml
<context:component-scan base-package="org.jeecgframework.core.aop" />
spring-mvc-hibernate.xml (7 matches)
<context:component-scan base-package="org.jeecgframework.easypoi." />
<context:component-scan base-package="org.jeecgframework.core.common.dao." />
<context:component-scan base-package="org.jeecgframework.core.common.service." />
<context:component-scan base-package="org.jeecgframework.jwt.service."/>
<context:component-scan base-package="com.jeecg.">
<context:component-scan base-package="org.jeecgframework.web.">
<context:component-scan base-package="com.zgg.">
spring-mvc-timeTask.xml
<context:component-scan base-package="org.jeecgframework.core.timer" />
spring-mvc.xml (2 matches)
<context:component-scan base-package="org.jeecgframework.web.,com.jeecg.,org.jeecgframework.jwt.,com.jeecg.crm.controller.,com.zgg.">
<context:component-scan base-package="springfox"/>
<context:component-scan base-package="org.jeecgframework.core.interceptors" />
<context:component-scan base-package="org.jeecgframework.core.aop" />
<context:component-scan base-package="org.jeecgframework.core.common.dao." />
<context:component-scan base-package="org.jeecgframework.core.common.service." />
<context:component-scan base-package="org.jeecgframework.core.timer" />
<context:component-scan base-package="org.jeecgframework.easypoi." />
<context:component-scan base-package="org.jeecgframework.jwt.service."/>
<context:component-scan base-package="org.jeecgframework.web.">
<context:component-scan base-package="org.jeecgframework.web.,org.jeecgframework.jwt.,com.jeecg.crm.controller.,com.zgg.">
<context:component-scan base-package="com.jeecg.">
<context:component-scan base-package="com.jeecg.crm" >
<context:component-scan base-package="com.zgg.*">
<context:component-scan base-package="springfox" />
<context:component-scan base-package="org.jeecgframework.core.,org.jeecgframework.easypoi.,org.jeecgframework.jwt.,org.jeecgframework.web.,com.jeecg.,com.jeecg.crm,com.jeecg.crm.controller.,com.zgg.*,springfox" />
方案:@ComponentScan("org.jeecgframework.core.,org.jeecgframework.easypoi.,org.jeecgframework.jwt.,org.jeecgframework.web.,com.jeecg.,com.jeecg.crm,com.jeecg.crm.controller.,com.zgg.*,springfox")
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}