开发者

Spring configuration in GWT Project?

I am developing a GWT-Spring-Hibernate project and I want to use Spring Autowired annotation in GWT Service Servlet but my autowired annotated service is not injected. it is null. Is there a configuration detail that I missed?

I add

<context:annotation-config />
<context:component-scan base-package="com.org"开发者_运维知识库 />

to my ApplicationContext.xml and I have annotated my service as @Service("myService")

@Autowired
MyService myService;  // This is null so WHY?


You need to "autowire" your RPC servlets during initialization. Take a look here http://code.google.com/p/gwt-spring-starter-app/


Well, the class where the @Autowired annotation resides should also be in the spring context (i.e. annotated with @Component), but I doubt it will work if it is a GWT (i.e. client-side) class.


Is class you're trying to inject your service into actually a bean declared in Spring context? It should be, auto-wiring won't work otherwise.

It can either be declared explicitly or, provided that it's somewhere within your "com.org" hierrarchy it will be detected automatically IF it's annotated as @Component or one of other stereotypes provided by Spring.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜