2012-02-07 121 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註冊。