2012-02-07 120 views
0

How do I inject a Spring bean into Apache Wink?豆未注册

继现在,我使用眨眼弹簧支持,我想我已经建立了正确的事情。

web.xml文件包括:

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     classpath:META-INF/wink/wink-core-context.xml 
     classpath:applicationContext.xml 
    </param-value> 
</context-param> 

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

<servlet> 
    <servlet-name>restServlet</servlet-name> 
    <servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class> 
</servlet> 

<servlet-mapping> 
    <servlet-name>restServlet</servlet-name> 
    <url-pattern>/rest/*</url-pattern> 
</servlet-mapping> 

META-INF /眨眼/眨眼核心的context.xml包含:

<bean class="org.apache.wink.spring.Registrar"> 
    <property name="instances"> 
     <set> 
      <ref bean="myservice" /> 
     </set> 
    </property> 
</bean> 

<bean id="myservice" class="mystuff.ServiceImpl"/> 

有一个@Autowired注释中mystuff.ServiceImpl是注入其他Spring的东西,而mystuff.ServiceImpl实现了JAX-RS注释接口,并且其本身包含JAX-RS @Path("/services")注释。

我可以看到Spring加载这个东西就好了,包括myservice bean。但是,当我请求我的资源时,我找不到404。由于眨眼开始,我看到一对夫妇的日志条目可能表明问题:

applicationConfigLocation property was not defined

Using application classes null named in init-param applicationConfigLocation

有我错过了什么地方?有什么建议?

回答

0

问题是我误解了文档。

有一个弹簧配置META-INF/server/wink-core-context.xml提供wink-spring-support。这注册了实际进行设置的BeanPostProcessors,并且必须从contextConfigLocation引用。

我以为我把我的配置放在那里,这就解释了为什么应用程序没有在启动时使用Wink注册。