CXF中使用Autowired注解无法注入bean的有关问题
来源:互联网 发布:Linux cookie设置 编辑:程序博客网 时间:2024/06/06 07:52
在WebService的implementor中用@Autowired注入用@Component,@Resposrity,@Service注解标记的bean,都失败了,得到的都是null。google一番后找到了结果,只要改变一下配置文件写法即可。
package aitajian.ws;import javax.annotation.Resource;import javax.jws.WebService;import aitajian.entity.Order;import aitajian.mapper.ReimburseMapper;@WebServicepublic class OrderWsIpml implements OrderWs {@Autowiredprivat@Autowirede ReimburseMapper rm;public OrderWsIpml() {System.out.println("OrderWsIpml()");}@Overridepublic Order getOrderById(int id) {System.out.println("server getOrderById() "+id);System.out.println(rm+"-------------");System.out.println(rm.getReimburse(3));return new Order(id,"飞机",1000000);}}
原配置:
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:jaxws="http://cxf.apache.org/jaxws"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"><!-- 引入cxf的一些核心配置 --><import resource="classpath:META-INF/cxf/cxf.xml" /><import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /><import resource="classpath:META-INF/cxf/cxf-servlet.xml" /><jaxws:endpointid="orderWS"implementor="aitajian.ws.OrderWsIpml" address="/orderws" /></beans>
新配置:
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:jaxws="http://cxf.apache.org/jaxws"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"><!-- 引入cxf的一些核心配置 --><import resource="classpath:META-INF/cxf/cxf.xml" /><import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /><import resource="classpath:META-INF/cxf/cxf-servlet.xml" /><bean name="orderWsIpml" class="aitajian.ws.OrderWsIpml"/> <jaxws:endpointid="orderWS"implementor="#orderWsIpml" address="/orderws" /></beans>
主要区别是原本jaxws中的implementor属性是直接写实现类的fullClass,现在改成ref bean的方式。
也可以使用@Component注解标记实现类为一个bean,然后implementor属性用# + bean的名字来reference这个bean即可。这和使用配置文件的方式来配置bean,写法是大同小异的。
2 0
- CXF中使用Autowired注解无法注入bean的有关问题
- @webservice 注解的类中使用@Autowired 进行bean注入,注入的bean调用时为空的问题
- spring boot 中@Autowired注解无法自动注入的错误
- spring boot 中@Autowired注解无法自动注入的错误
- 关于Test类中不能使用Autowired注入bean的问题。。。
- Spring Bean装配--Autowired注解注入说明
- Interceptor无法用Autowired自动注入Bean
- 解决非controller使用@Autowired注解注入为null问题
- 解决spring-boot 中 bean无法注入的问题
- 关于SpringBoot bean无法注入的问题(与文件包位置有关)
- Spring中@Resource、@Autowired、@Qualifier的注解注入及区别
- Spring中@Resource、@Autowired、@Qualifier的注解注入及区别
- Spring中@Resource、@Autowired、@Qualifier的注解注入及区别
- SpingBoot集成shiro,MyRealm中无法@Autowired注入Service的问题
- Autowired注解的使用
- @Autowired注解的使用
- SpringBoot bean无法注入的问题
- Spring Bean装配--@Qualifier结合@Autowired注解注入说明
- xcode编译时,有第三方库时,编译设置build active architecture only问题
- Vim 使用大全
- PowerDesigner生成SQL脚本时表名、字段名带引号问题及解决方法
- xcode和vs对比
- 微信小程序-传递多个参数与事件处理
- CXF中使用Autowired注解无法注入bean的有关问题
- 存储图片路径方式保存和显示图片
- Android studio记录
- FILE内容和fd之间的关系
- Windows下安装MariaDB
- 第五次实验
- HTML5废除元素
- java学习笔记(二十六)java中的io流
- QT学习笔记之QT网络编程