配置mybatis核心配置文件出现的问题

我在调试Spring程序时,出现下面这个问题:

九月 27, 2022 12:01:37 下午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao ' of bean class [com.itheima.service.impl.UserServiceImpl]: Bean property 'userDao ' is not writable or has an invalid setter method. Did you mean 'userDao'?
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao ' of bean class [com.itheima.service.impl.UserServiceImpl]: Bean property 'userDao ' is not writable or has an invalid setter method. Did you mean 'userDao'?
 

我找了好久,一直没找到问题所在,最后又重头仔细检查了一遍,发现我的配置文件出了问题

<bean id="userDao" class="com.itheima.dao.impl.UserDaoImpl"></bean>
<bean id="userService" class="com.itheima.service.impl.UserServiceImpl">
    <property name="userDao " ref="userDao"></property>
</bean>

我发现我在打userDao时,不小心多打了个空格,最后把空格删掉,程序成功运行。所以写代码一定要小心仔细啊。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值