@WebService
public class DeviceService implements IDeviceService{
@Autowired
private IAccountManager accountManager;
private Account findUserByUsername(String username){
return accountManager.findAccountByUserName(username);
}
}
当调用private IAccountManager accountManager,如果没有正确配置,会报错,没有注入,造成抛空指针的错误。
解决了, sping集成cxf的时候注入sping管理的bean的时候比如说service层,用annotation标注了@Service
<bean id="dvrService" class="com.zhaohai.automation.device.webservice.DvrServiceImpl">
<property name="accountManager">
<ref bean="accountManagerImpl"/>
</property>
</bean>

本文探讨了在 Spring 集成 CXF 过程中遇到的 Bean 注入问题,特别是当使用 @Autowired 注解时,如果配置不正确会导致空指针异常。通过 XML 配置方式成功解决了这一问题。
226

被折叠的 条评论
为什么被折叠?



