簡體   English   中英

Spring Web App-CannotLoadBeanClassException找不到名稱為“ somename”的bean的類[package]

[英]Spring Web App - CannotLoadBeanClassException Cannot find class [package] for bean with name 'somename'

如果有人能解決我的問題,我將不勝感激。 我搜索並發現了很多類似的問題。 但無法找到解決方案。 對於同樣的問題我深表歉意。 但是我對此問題感到困惑和沮喪。

我有一個Web應用程序,在Eclipse上部署了許多項目。 我正在使用spring框架。 一切都很好。 我在eclipse中清理了所有項目,然后啟動了服務器。 我的瀏覽器拋出此錯誤。 我嘗試重新啟動服務器和所有可能的修復程序,但沒有任何效果。

SEVERE: Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class[org.company.ain.authenticate.AuthenticateUser] for bean with name 'authenticate' 

這是我的.xml文件

<bean name="authenticate" class="org.company.ain.authenticate.AuthenticateUser">
        <property name="dataSource" ref="dataSource"/>
    </bean>

我想知道兩件事。

  • 一旦我清理了所有項目,日食是否會抹掉我的類路徑?
  • 我上述問題的解決方案是什么?

我的工作示例適用於多個休眠狀態,希望對您有用。

數據源

 <!-- DATA SOURCE -->
    <bean id="_dataSourceProxy"
        class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="resourceRef" value="true" />
       <property name="jndiName" value="${connection.jndiName}"></property>
       <property name="lookupOnStartup" value="false"></property>
       <property name="cache" value="false"></property>
       <property name="proxyInterface" value="javax.sql.DataSource"></property>
    </bean>

冬眠

 <!-- HIBERNATE -->
 <bean id="_hibernateSessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

    <property name="dataSource">
        <ref bean="_dataSourceProxy"></ref>
    </property>

    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            <prop key="hibernate.connection.SetBigStringTryClob">true</prop>
            <prop key="hibernate.jdbc.batch_size">0</prop>
            <prop key="hibernate.jdbc.use_streams_for_binary">false</prop>
            <prop key="javax.persistence.validation.mode">none</prop>
            <prop key="connection.useUnicode">true</prop>   
            <prop key="connection.characterEncoding">utf-8</prop>


            <prop key="hibernate.connection.defaultNChar">true</prop>
            <prop key="hibernate.show_sql">true</prop>

        </props>
    </property>

    <property name="mappingResources">
        <list>
            <value>hibernate/content/Content.hbm.xml</value>
            <value>hibernate/content/ContentMeta.hbm.xml</value>
        </list>
    </property>

</bean>

休眠會議

 <!-- Content Repo -->
    <bean id="_contentRepository"
        class="XXXX">
        <aop:scoped-proxy/>
        <property name="_senderEmail" value="${smtp.senderEmail}"></property>    
        <property name="_hibernateSessionFactory">
            <ref bean="_hibernateSessionFactory"></ref>
        </property>
        <property name="_authService">
            <ref bean="_authService"></ref>
        </property>   
        <property name="_languageRepository">
            <ref bean="_languageRepository"></ref>
        </property>  
        <property name="_locationRepository">
            <ref bean="_locationRepository"></ref>
        </property>          
        <property name="_velocityEngine">
            <ref bean="_velocityEngine"></ref>
        </property>
        <property name="_mailSender">
            <ref bean="_mailSender"></ref>
        </property>                                                   
    </bean>

回購示例:

<!-- Location Repo -->
    <bean id="_locationRepository"
        class="XXXX">
        <property name="_hibernateSessionFactory">
            <ref bean="_hibernateSessionFactory"></ref>
        </property>
    </bean>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM