Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'dataSource' of bean class [com.liuyang.jdbc.PersonDao]: No property 'dataSource


这个错误是说我的启动失败了。这类问题要从配置文件中开始找原因,我用的是spring框架,所以我从application.中找的原因

然后对比路径,对比文件的命名和id,都没有问题,为什么会在启动的时候找不到dataSource,我想到应该是少包,但是,找寻发现包也没有问题。

最后发现是这里错了

这里是重点:::!!!!!

     我的getter和setter的方法中设置的dateSource,而配置文件想要注入的是dataSource,两个名称不一致,难怪机器找不到我的文件的class,更改

           

<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<bean id="personDao" class="com.liuyang.jdbc.PersonDao">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>

这里所有的dataSource为dateSource,或者更改类中的名称,dateSource为dataSource,连同getter和setter一起才有效。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



猜您在找 Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'URIType' of bean class Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception spring和mybatis整合报错:org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError 【错误解决】Error creating bean with name 'transactionManager' :nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/ 使用springmvc时报错org.springframework.beans.NullValueInNestedPathException: Invalid property 'department' of bean class [com.atguigu.springmvc.crud.entities.Employee]: Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with na org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.DataSourceTransactionManager#0' defined in class path resource [spring-mybat org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is 错误之Request processing failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM