Spring 无法实例化bean类:指定的类是接口

Spring 无法实例化bean类:指定的类是接口,spring,Spring,我知道有类似于此问题的线程。下面是我的类,我正在spring.xml文件中配置它。实际上,HumanResourceService是一个只有一个方法的接口 @Endpoint public class HolidayEndpoint { @Autowired private HumanResourceService humanResourceService; @Autowired public HolidayEndpoint(HumanResourceServ

我知道有类似于此问题的线程。下面是我的类,我正在spring.xml文件中配置它。实际上,HumanResourceService是一个只有一个方法的接口

@Endpoint
public class HolidayEndpoint {

    @Autowired
    private HumanResourceService humanResourceService;

    @Autowired
    public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException {
        this.humanResourceService = humanResourceService;
    }
}
我的问题是,在我的spring.xml文件中,当我将HumanResourceService定义为bean时,它不能被实例化,因为这是一个接口。如何在spring配置文件中提到接口。下面是我的spring.xml文件

<bean id="holidayEndpoint" class="com.mycompany.hr.ws.HolidayEndpoint" autowire="constructor" >
     <property name="humanResourceService" ref="humanResourceService" />
</bean>
<bean id="humanResourceService" class="com.mycompany.hr.service.HumanResourceService" />

不行,Spring需要一些它可以用来创建实例的东西,接口不够


在spring.xml中,id=“humanResourceService”bean的class属性的值应该是实现类的名称,而不是接口。Spring需要您告诉它您希望它为此使用什么实现类。

当我使用id=“humanResourceService”为bean提供class属性值作为我的implementataion类时,我得到以下错误“没有[com.mycompany.hr.service.humanResourceService]类型的合格bean”为依赖项找到:至少需要1个符合此依赖项autowire候选项条件的bean。依赖项批注:{};嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:“