Error creating bean with name ‘userController‘: Unsatisfied dependency expressed through field #####

项目场景:

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="">这个地方引用错了,注意包名。注意大小写
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
'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。如何解决这个问题? 回答: 这个报错是由于在Spring项目中,创建名为'userController'的bean时,发现依赖的'userService'无法满足。具体报错信息可能有多种形式,如引用[1]和引用[3]所示。其中,引用[1]中的报错信息表明'userController'依赖的'userService'又依赖于'userMapper',而'userMapper'无法满足依赖。引用[3]中的报错信息则更详细地描述了解决过程中的一些尝试。 解决这个问题的方法有多种,以下是一些常见的解决方案: 1. 确保依赖的bean已经正确地配置和注册。检查配置文件,确保'userService'和'userMapper'的bean定义正确,并且已经被正确地扫描和注册到Spring容器中。 2. 检查依赖注入的注解。确保在'userController'中使用了正确的注解来注入'userService',例如@Autowired注解。 3. 检查依赖的类和接口的包路径。确保'userService'和'userMapper'的包路径正确,以便Spring能够正确地扫描和识别它们。 4. 检查依赖的版本兼容性。有时候,依赖的版本不兼容可能导致无法满足依赖。确保所有依赖的版本兼容,并且没有冲突。 5. 检查依赖的类和接口的命名规范。确保'userService'和'userMapper'的命名符合Spring的命名规范,以便Spring能够正确地识别它们。 根据具体的报错信息和项目配置,可以根据上述解决方案逐一排查和解决问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值