当前位置: 代码迷 >> Java Web开发 >> Spring配置文件的问题
  详细解决方案

Spring配置文件的问题

热度:321   发布时间:2008-08-06 14:53:53.0
Spring配置文件的问题
[bo]提示错误 :
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.lfw.sh.manager.impl.UserManagerImpl#10b4b2f' defined in class path resource [applicationContext-commom.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required
java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required[/bo]

Spring配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
            value="com.mysql.jdbc.Driver">
        </property>
        <property name="url" value="jdbc:mysql://localhost:3306/test"></property>
        <property name="username" value="root"></property>
        <property name="password" value="88888888"></property>
    </bean>
    
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">
                    true
                </prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/lfw/sh/domin/User.hbm.xml</value>
                </list>
        </property></bean>
    
    
    <!--Hibernate TransactionManager-->
    <bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

   <!--Base TransactionProxyed Service Bean-->
    <bean id="baseTxService"
          class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
          abstract="true">
        <property name="transactionManager" ref="transactionManager"/>
        <property name="proxyTargetClass" value="true"/>
           
        <property name="transactionAttributes">
            <props>
                <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="save*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="updateBillSeq*">PROPAGATION_REQUIRED,ISOLATION_SERIALIZABLE</prop>
                <prop key="remove*">PROPAGATION_REQUIRED</prop>
                <prop key="submit*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
    </bean>

    
    
     <bean id="userManager" parent="baseTxService">
        <property name="target">
            <bean class="com.lfw.sh.manager.impl.UserManagerImpl"  />
        </property>
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>
    </beans>
搜索更多相关主题的帖子: Spring  文件  

----------------解决方案--------------------------------------------------------
'com.lfw.sh.manager.impl.UserManagerImpl#10b4b2f' defined in class path resource
[applicationContextcommom.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required
java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required

Initialization of bean failed;初始化bean,失败,原因,
   <bean id="userManager" parent="baseTxService">
        <property name="target">
            <bean class="com.lfw.sh.manager.impl.UserManagerImpl"  />
        </property>
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>
userManager看看这里面有没有father方法
----------------解决方案--------------------------------------------------------
com.lfw.sh.manager.impl.UserManagerImpl这个类中必须要有sessionFactory属性,查看一下你的代码中是否sessionFactory,并且还要有对应的set方法
----------------解决方案--------------------------------------------------------
  相关解决方案