我正在尝试使gwt-2.7与spring-4.2.3一起使用。配置是:
web.xml
<!-- spring config -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring GWT integration -->
<servlet>
<servlet-name>springGwtRemoteServiceServlet</servlet-name>
<servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>springGwtRemoteServiceServlet</servlet-name>
<url-pattern>/idp_web/service/*</url-pattern>
</servlet-mapping>
应用程序上下文.xml
<beans
...
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
....
default-lazy-init="true">
<!-- auto-inject bean by annotation mechanism -->
<context:component-scan
base-package="com.vsi.idp.analysis.server,
com.vsi.idp.base.server,
com.vsi.idp.kpi.server,
com.vsi.idp.map.server,//SeniorQueryServiceImpl is under this package
com.vsi.idp.statistics.server" />
//other configurations
</beans>
GWT 服务
@RemoteServiceRelativePath("service/querySenior")
public interface SeniorQueryService extends RemoteService{...}
服务内涵
@Service("querySenior")
public class SeniorQueryServiceImpl extends RemoteServiceServlet implements SeniorQueryService{...}
Spock单元测试工作正常
@ContextConfiguration(locations = "file:war/WEB-INF/applicationContext.xml")
public class SeniorQueryServiceImplTest extends Specification{
@Autowired
SeniorQueryServiceImpl service
def "query by full address"(){
//blabla
}
}
运行 gwt 项目告诉:
Failed to load resource: the server responded with a status of 500 (Server Error)
错误堆栈如下所示:
[WARN] Exception while dispatching incoming RPC call
java.lang.IllegalArgumentException: Spring bean not found: querySenior
at org.spring4gwt.server.SpringGwtRemoteServiceServlet.getBean(SpringGwtRemoteServiceServlet.java:96)
at org.spring4gwt.server.SpringGwtRemoteServiceServlet.getBean(SpringGwtRemoteServiceServlet.java:55)
at org.spring4gwt.server.SpringGwtRemoteServiceServlet.processCall(SpringGwtRemoteServiceServlet.java:31)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:373)
我认为:
1,"500(server error)" tells that gwt has recognized spring service
2,spring service unit test works fine,so spring configuration is right
问题可能来自spring4gwt,如何解决这个问题?