繁体   English   中英

Spring Autowired gwt RemoteServiceServlet实现类为null

[英]Spring Autowired gwt RemoteServiceServlet implement class is null

我的项目中有两个gwt RemoteServiceServlet,它使用了GWT框架,如下所示

@RemoteServiceRelativePath("AuthService")
public interface AuthService extends RemoteService {
}

public class AuthServiceImpl extends RemoteServiceServlet implements AuthService
{
     @Autowired
     private StoredService storeService;
}

@RemoteServiceRelativePath("webService")
public interface WebService extends RemoteService
{
}

public class WebServiceImpl extends RemoteServiceServlet implements WebService
{
     @Autowired
     private LogService logService;
}

StoreService的@Autowired和LogService都可以使用。 但是,当我尝试自动连接AuthService中的WebService时,在运行时它将为null。

接口和实现位于不同的包中,分别是com.test.client.service和com.test.server.service。

我已经确认我的SpringApplication-context.xml在下面声明:

<context:component-scan
    base-package="com.test.client.service, com.test.server.service
>

也可以尝试在WebServiceImpl上添加@ Service,@ Component或@Configurable,但仍然无法使用。

覆盖WebServiceImpl的init()也不起作用。

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    WebApplicationContextUtils.getWebApplicationContext(config.getServletContext())
        .getAutowireCapableBeanFactory().autowireBean(this);
}

那是因为RemoteService导致自动接线无法正常工作吗? 任何帮助表示赞赏。

谢谢

我使用以下内容将GWT-RPC集成到Spring中。 我是6年前写的,但从未见过需要进行更改。 它是老派的,并且有效。 它将GWT-RPC服务建模为Spring MVC控制器。 您可以将任何东西自动连接到那些控制器中。

我在另一个答案中提到了它,因此我将发布一个链接: https : //stackoverflow.com/a/30838630/4982193

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM