首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

BeanDefinitionStoreException错误,详细贴,请刚才的们再看看,

2012-02-08 
BeanDefinitionStoreException异常,详细贴,请刚才的大虾们再看看,急~各位大虾帮帮忙,小弟刚接触spring,但

BeanDefinitionStoreException异常,详细贴,请刚才的大虾们再看看,急~
各位大虾帮帮忙,小弟刚接触spring,但是在用SSH时候读取Spring配置文件的时候出现的错误如下: 
org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'accountDAO' defined in file [/WEB-INF/applicationContext.xml]: Bean class [com.worthtech.billportal.dao.hibernate.AccountHibernateDAO] not found; nested exception is java.lang.ClassNotFoundException: com/worthtech/billportal/dao/AccountDAO 

java.lang.ClassNotFoundException: com/worthtech/billportal/dao/AccountDAO 
  ...... 

我已经写了setter,getter了啊,怎么还报错啊?如下:
package com.worthtech.billportal.service.imp;

import java.util.List;
import com.worthtech.billportal.bean.Account;
import com.worthtech.billportal.dao.AccountDAO;
import com.worthtech.billportal.exception.SCException;
import com.worthtech.billportal.service.AccountService;

public class AccountServiceImp implements AccountService{
private AccountDAO accountDAO;
public void save(Account account) throws SCException {
// TODO Auto-generated method stub
this.getAccountDAO().save(account);
}
public List getAllAccount(){
return this.getAccountDAO().getAllAccount();
}
public AccountDAO getAccountDAO() {
return accountDAO;
}
public void setAccountDAO(AccountDAO accountDAO) {
this.accountDAO = accountDAO;
}

}
Spring 配置如下(部分): 

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
  <property name="dataSource"> <ref local="dataSource"/> </property> 
  <property name="mappingResources"> 
  <list> 
  <value>com/worthtech/billportal/bean/Account.hbm.xml </value> 
  </list> 
  </property> 
  <property name="hibernateProperties"> 
  <props> 
  <prop key="hibernate.dialect">${hibernate.dialect} </prop> 
  <prop key="hibernate.show_sql">${hibernate.show_sql} </prop> 
  <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size} </prop> 
  <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size} </prop> 
  </props> 
  </property> 
  </bean> 

<!--dao class--> 
  <bean id="accountDAO" class="com.worthtech.billportal.dao.hibernate.AccountHibernateDAO"> 
  <property name="sessionFactory"> 
  <ref local="sessionFactory"/> 
  </property> 
  </bean> 


<bean id="accountServiceTarget" class="com.worthtech.billportal.service.imp.AccountServiceImp" autowire="byName"/> 
<!--Proxy Class--> 
  <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> 
  <property name="transactionManager"> 
  <ref bean="myTransactionManager"/> 
  </property> 
  <property name="transactionAttributes"> 
  <props> 
  <prop key="create*">PROPAGATION_REQUIRED,-com.worthtech.billportal.exception.SCException </prop> 
  <prop key="save*">PROPAGATION_REQUIRED,-com.worthtech.billportal.exception.SCException </prop> 


  <prop key="remove*">PROPAGATION_REQUIRED,-com.worthtech.billportal.exception.SCException </prop> 
  <prop key="update*">PROPAGATION_REQUIRED,-com.worthtech.billportal.exception.SCException </prop> 
  <prop key="del*">PROPAGATION_REQUIRED,-com.worthtech.billportal.exception.SCException </prop> 
  <prop key="*">PROPAGATION_REQUIRED,readOnly </prop> 
  </props> 
  </property> 
  </bean> 
<!--service--> 
  <bean id="accountService" parent="txProxyTemplate"> 
  <property name="target"> 
  <ref bean="accountServiceTarget"/> 
  </property> 
  </bean> 


AccountHibernateDAO 类如下(仔细看看包!!!): 

package com.worthtech.billportal.dao.hibernate; 

import java.util.List; 
import com.worthtech.billportal.bean.Account; 
import com.worthtech.billportal.dao.AccountDAO; 
import com.worthtech.billportal.exception.SCException; 
import com.worthtech.billportal.util.AbstractManager; 

public class AccountHibernateDAO extends AbstractManager implements AccountDAO {//AbstractManager继承自HibernateDaoSupport 

public void save(Account account) throws SCException { 
try{ 
this.getHibernateTemplate().save(account);//获得sessionFactory 
}catch(Exception e){ 
throw new SCException("数据失败!"); 



public List getAllAccount() { 
List list = this.getHibernateTemplate().find("from Account"); 
System.out.println("dsfdsfa"+list.size()); 
return list; 




请大家看看。哪里出了问题?

[解决办法]
<bean id="accountDAO" class="com.worthtech.billportal.dao.hibernate.AccountHibernateDAO"> 
<property name="sessionFactory"> 
<ref local="sessionFactory"/> 
</property> 
</bean>

 <bean id="accountService" parent="txProxyTemplate"> 
<property name="target"> 
<ref bean="accountServiceTarget"/> 
</property> 
</bean>

---------------
先在这里加上试试
<bean id="accountService" parent="txProxyTemplate"> 
<property name="proxyInterfaces">
<list>
<value>
com.worthtech.billportal.service.AccountService
</value>
</list>
</property>
------------
不行的话把红色的地方a大写试试
[解决办法]

探讨
<bean id="accountDAO" class="com.worthtech.billportal.dao.hibernate.AccountHibernateDAO">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

<bean id="accountService" parent="txProxyTemplate">
<property name="target">
<ref bean="accountServiceTarget"/>
</property>
</bean>

---------------
先在这里加上试试

热点排行