spring,struts,整合后整合iBATIS

本文记录了整合Struts、Spring与iBATIS过程中遇到的问题及解决方案,包括配置属性文件的位置、数据源类找不到的异常处理以及加载依赖库的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

整合struts,spring后,整合iBATIS,遇到一些问题:

1:创建属性文件 db.properties,首次创建在src目录下,

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
           <property name="locations">  
               <list>  
                   <value>/db.properties</value>  
               </list>  
           </property>  
       </bean>  

发现无法加载,报错。

最后,将db.properties文件移至WEB-INF下,加载成功。

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
           <property name="locations">  
               <list>  
                   <value>/WEB-INF/db.properties</value>  
               </list>  
           </property>  
       </bean>  

2:

报错:org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

解决方法:加载 commons-dbcp .jar

3:报错:java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

在MyEclipse安装文件中查找到 commons-pool.jar 加载入项目

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值