当前位置: 首页 > 知识库问答 >
问题:

创建名为'trackiHuntServiceImpl'的bean时出错:通过字段'deviceService'表示不满意的依赖关系

贺华容
2023-03-14

我使用的是SpringV1。4.0.释放我得到一个异常“org.springframework.beans.factory.unsatifiedpendencyException:创建名为“trackiHuntServiceImpl”的bean时出错:通过字段“deviceService”表示的未满足的依赖关系”。其方案是多模块的。

我列出了主要的课程代码:

    @Import({PrimaryRepositoryConfig.class, 
    AuditRepositoryConfig.class,
    PaypalConfig.class,
    BraintreeConfig.class,
    CommonConfig.class,
    ElasticsearchConfig.class
})
@ComponentScan(basePackages ={"com.trackimo.server.model" ,
        "com.trackimo.server.dao",
        "com.trackimo.server.services",
        "com.trackimo.server.services.account",
        "com.trackimo.server.services.email",
        "com.trackimo.server.services.common",
        "com.trackimo.server.services.location",
        "com.trackimo.server.services.user",
        "com.trackimo.server.services.trackihunt",
        "com.trackimo.server.services.device",
        "com.trackimo.server.audit.model",
        "com.trackimo.server.audit.dao",
        "com.trackimo.server.utils.converters",
        "com.trackimo.server.worker",
        "com.trackimo.quartz.config"},
        excludeFilters = @ComponentScan.Filter(IgnoreDuringScan.class)
)
@SpringBootApplication(exclude = { DispatcherServletAutoConfiguration.class })
@EnableScheduling
@EnableAsync
public class QuartzApplication {

public static void main(String[] args) {
        SpringApplication.run(QuartzApplication.class, args);
    }

}



2019-10-11 16:57:37,072 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'trackiHuntServiceImpl': Unsatisfied dependency expressed through field 'deviceService': Error creating bean with name 'deviceServiceImpl': Unsatisfied dependency expressed through field 'emailService': Error creating bean with name 'emailServiceImpl': Unsatisfied dependency expressed through field 'eMailMessageSender': No qualifying bean of type [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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 [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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.UnsatisfiedDependencyException: Error creating bean with name 'emailServiceImpl': Unsatisfied dependency expressed through field 'eMailMessageSender': No qualifying bean of type [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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 [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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.UnsatisfiedDependencyException: Error creating bean with name 'deviceServiceImpl': Unsatisfied dependency expressed through field 'emailService': Error creating bean with name 'emailServiceImpl': Unsatisfied dependency expressed through field 'eMailMessageSender': No qualifying bean of type [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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 [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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.UnsatisfiedDependencyException: Error creating bean with name 'emailServiceImpl': Unsatisfied dependency expressed through field 'eMailMessageSender': No qualifying bean of type [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: 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 [com.trackimo.server.services.email.DynamicEmailService] found for dependency [com.trackimo.server.services.email.DynamicEmailService]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

共有1个答案

公羊晟
2023-03-14

Spring无法创建bean trackiHuntServiceImpl,因为它无法创建bean deviceServiceImpl,因为它无法创建bean emailServiceImpl,因为它依赖于它未定义的DynamicEmail Service类型的bean eMailMessageSender。

基本上,您必须定义DynamicMailService类型的bean。当您解决这个问题时,可能还会缺少其他定义。祝你好运

 类似资料: