Error creating bean with name 'dateSource' defined in file 錯誤信息


問題的原因:

  在web項目中搭建SSM框架,啟動Tomcat時出現錯誤信息

    有配置文件:applicationContext-mybatis.xml (Spring配置)

          spring-servlet.xml(SpringMVC配置)

          mybatis-config.xml(Mybatis配置)

          log4j.properties

          jdbc.properties

截取部分錯誤信息片段:

- (1912 ms) - [ERROR] 2016-08-30 22:48:02,924 org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dateSource' defined in file [D:\Program Files\apache-tomcat-8.0.33\apache-tomcat-8.0.33\webapps\springmvcproject-test\WEB-INF\classes\applicationContext-mybatis.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'driver' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'driver' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1423)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)

 

嘗試過的辦法有:

  更換數據源的配置

  更換jdbc.properties

  重寫applicationContext-mybatis.xml

  清空Tomcat所在目錄下的work文件夾與webapps文件夾

  更換過jar包

  但錯誤依舊。。。。。

  最后,將Spring配置文件applicationContext-mybatis.xml的名稱

        改為  application-mybatis.xml

    錯誤消失!!!

 

錯誤原因:

    初步認為是其他web項目下有同名的Spring配置文件applicationContext-mybatis.xml,

  在啟動Tomcat時造成混淆。

    考慮到之前清空過Tomcat目錄下的work文件夾與webapps文件夾,

  所以,暫時推斷為Tomcat緩存中的殘余。

    由於我也在學習Java的時期中,所以還需要研究,關於Tomcat緩存並不了解,

  如果有牛人路過,希望留下指點,感激不盡。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM