首先Spring的注入配置还是像一般的Spring一样注入
spring-config_ruleService.xml
<!-- 把产品信息的DAO的对象注入到service中 --> <bean id="RuleService" class="com.xxx.service.ruleWebservice.impl.RuleServiceImpl"> <!-- 注入Dao实例 --> <property name="ruleServiceDao" ref="ruleServiceDao"></property> </bean> <!-- 实例化Hibernate实现DAO --> <bean id="ruleServiceDao" class="com.xxx.dao.extend.impl.RuleServiceDaoImpl" parent="daoTemplate" />
不过CXF的配置文件要有注意的地方
cxf/webservice.xml
<!-- 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" /> <!-- 注册对外接口 implementor是实现类 address是web service地址 --> <jaxws:endpoint id="ruleService" implementorClass="com.xxx.service.ruleWebservice.RuleService" implementor="#RuleService" address="/ruleService" />
注意这个配置implementorClass就是配置这个service的interface,然后implementor就是去引用Spring容器中的RuleService这个bean,这样配置,就能在webservice的实现service中注入dao了。