org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'login' defined in file [E:\Java\tomcat\tomcat6\webapps\copycode\WEB-INF\classes\applicationContext.xml]: Cannot resolve reference to bean 'LoginService' while setting bean property 'LoginService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LoginService' defined in file [E:\Java\tomcat\tomcat6\webapps\copycode\WEB-INF\classes\applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.copycode.service.LoginService]: Specified class is an interface
[applicationContext.XML]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>


<!-- action  -->
<bean id="login"  class="com.copycode.action.LoginAction">
        <property name="LoginService" ref="LoginService"></property>
</bean>


<!-- service -->
<bean id="LoginService"  class="com.copycode.service.LoginService">
       <property name="LoginDao" ref="LoginDao"></property>
</bean>


      <!-- dao -->
     <bean id="LoginDao"   class="com.copycode.dao.LoginDao"> 
           
      </bean>
      
</beans>
不知道怎么搞的

解决方案 »

  1.   

    无法实例化一个接口
    com.copycode.service.LoginService这里需要使用实体类。
      

  2.   

    <!-- action -->
    <bean id="login" class="com.copycode.action.LoginAction">
    <property name="LoginService" ref="LoginService"></property>
    </bean>
    改Id为name
      

  3.   

    <bean id="login" class="com.copycode.action.LoginAction">
    LoginAction这个是接口吧
    class要指定到LoginAction这个接口的实现类
      

  4.   

    原来错误就一个,在DAO里注入Sessionfactory,就OK了