项目场景:
Spring项目中遇到的报错
Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframewo
提示:遇到这样的报错,第一步直接去Mapper.xml文件中找错
原因分析:
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="summary" jdbcType="VARCHAR" property="summary"/>
<result column="cover_img" jdbcType=" VARCHAR" property="coverImg"/>
<result column="price" jdbcType="INTEGER" property="price"/>
<result column="point" jdbcType="DOUBLE" property="point"/>
<result column="create_time" jdbcType="TIMESTAMP"
property="createTime"/>
解决方案:
这里xml文件中箭头处 多了个空格,将空格去掉就行了
遇到这样的报错一般就是你Mapper.xml文件有问题,可能写的太快没有注意到,所以细心最为重要
去掉后
还有可能是你的
<mapper namespace="">这个地方引用错了,注意包名。注意大小写