原 Webservice 接口暴露方式如下
//webservice 接口暴露 String address = "http://localhost:8088/MyWebService";
//使用Endpoint类提供的publish方法发布WebService,发布时要保证使用的端口号没有被其他应用程序占用
Endpoint.publish(address, new TestWebServiceImpl());
System.out.println("发布webservice成功!");
出现 @webservice 注解的类中使用@Autowired 进行bean注入,注入的bean调用时为空的问题,无法调用service、dao等

解决方式如下,使用@Bean 方式进行配置
package com.web.webservice; import javax.xml.ws.Endpoint; import
org.apache.cxf.Bus; import org.apache.cxf.jaxws.EndpointImpl; import
org.springframework.beans.factory.annotation.Autowired; import
org.springframework.context.annotation.Bean; import
org.springframework.context.annotation.Configuration; /** * cxf配置 */
@Configuration public class CxfConfig { @Autowired private Bus bus; @Autowired
private TestWebServiceImpl testWebService; @Bean public Endpoint endpoint(){
EndpointImpl endpoint = new EndpointImpl(bus, testWebService);
endpoint.publish("/MyWebService"); return endpoint; } }
默认服务在Host:port/services/*路径下 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信