1

I have a Wink application with some resources, on which I'd like to make some dependency injection of Spring beans. I defined my resource as bean following the example located here http://wink.apache.org/1.0/html/5.5%20Spring%20Integration.html, and injection is well made at startup.

However, when I call my resource, a new instance of the resource is created, according to JAX-RS spec. Spring is not used to create this new resource, so my dependencies are not injected.

The wink documentation page above states it's possible to change lifecycle of resources (so my injection would be made correctly), but there's no example for this.

I tried to play around with the @Scope annotation, but it didn't change anything... Anyone got a clue ? Thanks!

4

1 回答 1

0

您应该使用org.apache.wink.spring.Registrar 确保它出现在该instances部分中注册您的 bean,因此它将引用一个 bean,并且将使用在 spring 上下文中声明的范围。

另请查看此帖子,您可能会发现它很有帮助。

于 2013-11-17T08:29:55.853 回答