我有以下的主类:抽象类,接口和自动装配Autowired
public class Startup implements UncaughtExceptionHandler {
@Autowired
private MessageListener messageListener;
private static Startup startup;
public static void main(String[] args) {
Startup start = new Startup();
start.init(args);
}
public void init(String[] args) {
context = new ClassPathXmlApplicationContext("applicationContext.xml");
startup = (Startup) context.getBean("startup");
startup.start(); //here the messageListener is used
}
//这里去调用其中的MessageListener使用 }
@Component
public class ProdMessageListener
extends AbstractMessageListener implements MessageListener {...}
和
方法的主类public abstract class AbstractMessageListener
implements MessageListener {...}
以及
@Component
public interface MessageListener extends QueueAware {...}
@Component
public interface QueueAware {...}
我的Spring上下文用来定位所有的类和接口。 然而豆无法识别和获取:
No qualifying bean of type [com.ware.messaging.listener.MessageListener] found for dependency.
任何想法,为什么自动连接不起作用?
自动线在哪里? – Kent 2013-04-11 14:25:48
编译错误:MessageListener正在扩展一个接口 – MStodd 2013-04-11 14:29:30
嗯,不是。接口可以扩展接口。看到[链接](http://stackoverflow.com/questions/616684/java-interface-extends-questions) – luksmir 2013-04-11 14:58:17