请原谅,如果我使用术语错误,但我是新来的java-web开发和春天。 纠正我的假设,如果我错了。如何将Spring DI与2个或更多的servlet一起使用?
我想创建一个WebApp,它使用Vaadin进行UI和Spring MVC的RESTful Web服务。 所以,我想我需要2个Servlets。 一个服务于Vaadin,另一个服务于Spring MVC。
我有一些通用的dao bean,这两个servlet都使用它,所以我认为我可以使用Spring和@Autowired注释将这些@Repository和@Component标记的bean注入MVC和Vaadin - “程序(App | Servlet的)”。 (通过弹簧组件扫描功能发现)
但我无法让它工作。 Spring-MVC-应用程序 - 工作。我注释了所有的@Controllers,所有的东西都是自动的@Autowired。
但在Vaadin我总是得到:
SCHWERWIEGEND: Servlet.service() for servlet [hello] in context with path [/pliste] threw exception [javax.servlet.ServletException: failed to acquire new instance of class net.d21.pliste.HelloWorld] with root cause
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [net.d21.pliste.HelloWorld] is defined: expected single bean but found 0:
我想,我的基本问题是,如何注入依赖一般为2周不同的servlet? (在我的情况下,它是Vaadin和MVC,但我认为它是可替换的)。
您的评论,espacialy您的链接帮助我得到它的工作。谢谢! – crushervx 2012-03-15 12:57:33