【发布时间】:2013-02-13 12:18:45
【问题描述】:
我在 Spring 中使用 GWT。我遇到了在RemoteServiceServlet 中使用@Autowired bean 的问题。出于某种原因,这不会自动工作,我需要使用@Configurable 才能使其正常工作。我关注了this approach,但我仍然得到NullPointerException 的@Autowired bean:
@Configurable
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class AServiceImpl extends RemoteServiceServlet implements AService {
@Autowired
private IABean aBean;
@Override
public void aMethodFromAService(Args arg[]) {
aBean.aMethodOfABean(); // this gives a NullPointerException
}
}
@Component
public class ABean implements IABean {
...
}
关于发生了什么的任何指导?我需要提供任何额外信息吗?
【问题讨论】:
-
你在哪里/如何在 Spring 中声明你的 ABean? XML 还是注解?
-
注解,编辑原帖
-
您是否在应用程序上下文文件中有
以使 ABean 成为注入的候选对象。 -
是的,我之前成功使用了几个@autowired。以某种方式导致问题的是带有 GWT 的 RemoteServiceServlet
标签: spring gwt aspectj spring-aop