我有這個自動裝配麻煩:春季預計將有至少1 Bean上有資格作爲自動裝配候選人,這種依賴性
@Controller
public class ChiusuraController {
@Autowired
private ChiusuraProvider chiusuraProvider;
}
與這個bean:
@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抽象類。
如果我的類實現了多個接口,該怎麼辦? – user1050619
等等......你只是救了我的命。我使用了註釋版本@EnableAspectJAutoProxy(proxyTargetClass = true)。謝謝! –