在尝试使用 spring 依赖注入而不是guice时,出现以下错误
没有定义名为“dispatch”的bean
[WARN] /dispatch/
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dispatch' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1083)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)
at org.springframework.web.context.support.HttpRequestHandlerServlet.init(HttpRequestHandlerServlet.java:57)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:342)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
你能帮忙吗?
web.xml 内容如下
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatch</servlet-name>
<servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatch</servlet-name>
<url-pattern>/dispatch/*</url-pattern>
</servlet-mapping>
SeverModule 类是
package com.khush.util.server.spring;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.gwtplatform.dispatch.server.actionvalidator.ActionValidator;
import com.gwtplatform.dispatch.server.spring.HandlerModule;
import com.gwtplatform.dispatch.server.spring.actionvalidator.DefaultActionValidator;
import com.gwtplatform.dispatch.server.spring.configuration.DefaultModule;
import com.khush.util.shared.action.RetrieveAccountsAction;
@Configuration
@Import(DefaultModule.class)
public class ServerModule extends HandlerModule {
public ServerModule() {
}
@Bean
public RetrieveAccountsHandler getRetrieveAccountsHandler() {
return new RetrieveAccountsHandler();
}
@Bean
public ActionValidator getDefaultActionValidator() {
return new DefaultActionValidator();
}
protected void configureHandlers() {
bindHandler(RetrieveAccountsAction.class, RetrieveAccountsHandler.class);
}
}
问候。