我对这个 Autowire 有问题:
@Controller
public class ChiusuraController {
@Autowired
private ChiusuraProvider chiusuraProvider;
}
用这个豆子:
@Service @Transactional
public class ChiusuraProvider extends ThreadProvider {
public void run() {}
}
延伸
public abstract class ThreadProvider extends Thread implements InitializingBean, Runnable, DisposableBean {
...
}
我收到此错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'chiusuraController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cinebot.service.ChiusuraProvider com.cinebot.web.controller.ChiusuraController.chiusuraProvider; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.cinebot.service.ChiusuraProvider] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
我看到如果我删除自动装配类的扩展 ThreadProvider,我没有得到这个错误 ,但我真的需要 ThreadProvider 抽象类。