【发布时间】:2011-11-21 23:13:43
【问题描述】:
我有一个运行良好的 CXF RESTful 服务。问题是当我尝试使用注释注入我的 DAO 时:
@Resource
private MyDAO myDAO;
它没有被注入。我的 JAX-RS 服务是 Spring 配置的,如下所示:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<jaxrs:server id="message" serviceClass="com.foo.MessageResourceImpl" address="/">
<jaxrs:features>
<cxf:logging/>
</jaxrs:features>
</jaxrs:server>
</beans>
DAO 正在由 Spring 初始化,并且我已经验证了 bean 在任何其他 POJO 中的工作,但不是 CXF 服务。此外,我在日志中看不到任何错误
【问题讨论】: