用Spring注入Apache Wink的bean没有注册

时间:2012-02-07 19:10:59

标签: spring jax-rs apache-wink

继续How do I inject a Spring bean into Apache Wink?

我现在正在使用wink-spring-support,我认为我的设置正确。

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 / wink / wink-core-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。当Wink启动时,我可以看到几个可能表明问题的日志条目:

applicationConfigLocation property was not defined

Using application classes null named in init-param applicationConfigLocation

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

1 个答案:

答案 0 :(得分:0)

问题在于我对文档的误解。

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

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

相关问题