使用Spring注入Apache Wink的Bean未注册 [英] Beans injected into Apache Wink with Spring aren't registered

查看:161
本文介绍了使用Spring注入Apache Wink的Bean未注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

接着如何注入弹簧bean进入Apache Wink?

我现在正在使用wink-spring-support,我认为我已经正确设置了东西.

I'm now using wink-spring-support and I thought I had things set up correctly.

web.xml包括:

web.xml includes:

<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包含:

META-INF/wink/wink-core-context.xml contains:

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

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

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

There's a @Autowired annotation in mystuff.ServiceImpl that injects other Spring stuff, and mystuff.ServiceImpl implements a JAX-RS annotated interface and itself includes a JAX-RS @Path("/services") annotation.

我可以看到Spring很好地加载了这些东西,包括myservice bean.但是,当我请求资源时,找不到404.在Wink启动时,我可以看到一些可能表明该问题的日志条目:

I can see Spring loading up this stuff just fine, including the myservice bean. However when I request my resources, I get a 404 not found. As Wink starts, I can see a couple of log entries that might indicate the problem:

applicationConfigLocation property was not defined

Using application classes null named in init-param applicationConfigLocation

我在某处错过了什么吗?有什么建议吗?

Have I missed something somewhere? Any advice?

推荐答案

问题是我对文档的误解.

The problem was my misunderstanding the docs.

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

There is a Spring configuration META-INF/server/wink-core-context.xml provided with wink-spring-support. This registers the BeanPostProcessors that actually do the setup and must be referenced from contextConfigLocation.

我以为我在其中放置了配置,这说明了为什么启动时未向Wink注册该应用程序.

I thought that I put my configuration in there, which explains why the application didn't get registered with Wink on startup.

这篇关于使用Spring注入Apache Wink的Bean未注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆