我在用apache cxf 结合Spring框架开发webservice服务时,遇到一个这样的问题,请大家帮忙解决一下,问题描述如下:
webservice启动配置如下
Java代码
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<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:endpoint id="sqlExecuteService"
implementor="com.unicom.uniformdata.SqlExecuteServiceImpl"
address="/DesServer">
</jaxws:endpoint>
com.unicom.uniformdata.SqlExecuteServiceImpl类实现如下
Java代码
@javax.jws.WebService(
serviceName = "SqlExecuteServiceService",
portName = "SqlExecuteServicePort",
targetNamespace = "http://uniformdata.unicom.com",
endpointInterface = "com.unicom.uniformdata.SqlExecuteService")
public class SqlExecuteServiceImpl implements SqlExecuteService {
private DaoHelper daoHelper = null;
public SqlExecuteServiceImpl() {
System.out.println("实例化webservice实现类");
this.daoHelper = GlobalVariable.getInstance().getDaoHelper();
}
}
public DaoHelper getDaoHelper() {
return this.daoHelper == null ? (this.daoHelper = (DaoHelper) SpringUtils.getBean("daoHelper")): this.daoHelper;
}
其中daoHelper类的配置是通过配置的,是数据库操作对象。但在Tomcat启动时,是先实例化SqlExecuteServiceImpl,而不是daoHelper,导致SqlExecuteServiceImpl实例化失败,webservice服务启动失败。这个问题怎么解决。对cxf框架也不是很熟,希望大家能帮助解决一下,谢谢!