使用Spring注入Apache Wink的Bean未注册

编程入门 行业动态 更新时间:2024-10-27 06:25:45
本文介绍了使用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未注册

本文发布于:2023-11-16 02:08:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1600035.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未注册   Apache   Spring   Bean   Wink

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!