【出现错误的背景】

在使用Spring+SpringMVC+Mybatis SSM集成框架时,服务器启动就会报错。

【错误根源】

XML配置错误。

【解决方案】

第一步、查找springmvc.xml 配置文件中 是否添加了扫描注解的范围。

<!-- 开启扫描注解 -->
<context:component-scan base-package=""></context:component-scan>

(重要)base-package中要添加扫描注解范围。

<!-- 开启扫描注解 -->
<context:component-scan base-package="com.hyh.action,com.hyh.service.impl"></context:component-scan>

如果上一步没问题的话,看下面

第二步、检查mapper包中的xml。

<mapper >
<!-- 完成用户的账户信息验证 -->
<select id="userLogin" parameterType="com.hyh.entity.User"
resultType="com.hyh.entity.User">
select * from userInfo where phone=#{phone} and accoundpwd=#{accountpwd}
</select> </mapper>

(重要)mapper 标签中,一定要写namespace。

如下:

<mapper namespace="com.hyh.mapper.UserMapper">
<!-- 完成用户的账户信息验证 -->
<select id="userLogin" parameterType="com.hyh.entity.User"
resultType="com.hyh.entity.User">
select * from userInfo where phone=#{phone} and accoundpwd=#{accountpwd}
</select>
</mapper>

一般出现这些问题,无非是粗心、粗心、还是粗心。

另外一定要记住:有些关键字,能复制就复制,打字容易错。

,com.taotao.search.dao

我的错误 项目是sso的maven结构,然后在搭建solr服务的时候多添加了一个dao层的注入,用到注解@Repository,然而我的springmvc中扫描注解是<context:component-scan base-package="com.taotao.search.service"/>,只是<!-- 配置包扫描器,扫描所有带@Service注解的类 -->,在serviceimpl注入dao层对象,就会报创建对象错误,注入对象失败,改为<context:component-scan base-package="com.taotao.search.service,com.taotao.search.dao"/>,启动项目错误消失。

nested exception is org.springframework.beans.factory.BeanCreationException: 不能注入对象 创建对象失败 spring的更多相关文章

  1. Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with na

    问题: Springboot 启动时出错,报没法创建bean的错误,看到nested最后是关于mongoTemplate的错误. 过程: 看网上大多说的是修改mongoTemplate的配置,但是sp ...

  2. nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException

    You should autowire interface AbstractManager instead of class MailManager. If you have different im ...

  3. Error creating bean with name 'student': Unsatisfied dependency expressed through field 'teacher'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating

    有 有参构造但是没有无参构造...

  4. Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException:

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...

  5. Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException

    Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. M ...

  6. 开发Spring过程中几个常见异常(二):Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'a' define

    本异常是小编在运行自己另外一篇博文中的例子时遇到的.(附博文:http://www.cnblogs.com/dudududu/p/8482487.html) 完整异常信息: 警告: Exception ...

  7. 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;

    一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...

  8. 整合SSH时,遇到了org.springframework.beans.factory.BeanCreationException错误

    严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating ...

  9. Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field

    1 错误描述 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.s ...

随机推荐

  1. 【Unity笔记】物体的Transform操作:速度、旋转、平移

    例如,通过按键/摇杆来操作飞机在三维空间的飞行状态.包括速度(大小,方向).位移. public class ExampleClass : MonoBehaviour { public float s ...

  2. si4438 cca 侦听

    /* set GPIO0 for RSSI interrupt / CCA */txbuf[0] = CMD_GPIO_PIN_CFG;txbuf[1] = 27; /* GPIO[0] = 27: ...

  3. oracle 字符集 AL32UTF8、UTF8

    简介:ORACLE数据库字符集,即Oracle全球化支持(Globalization Support),或即国家语言支持(NLS)其作用是用本国语言和格式来存储.处理和检索数据.利用全球化支持,ORA ...

  4. MongoDB Shell 了解使用

    配置环境变量 WIN10系统:右键单击"此电脑"--属性--高级系统设置--高级--环境变量,添加C:\Program Files\MongoDB\Server\3.0\bin 如 ...

  5. Android代码内存优化建议-Android官方篇

    转自:http://androidperformance.com/ http://developer.android.com/intl/zh-cn/training/displaying-bitmap ...

  6. Linux make语法补充

    "-"表示此条命令出错,make也会继续执行后续的命令.如:"-rm main.o" 内置变量$@表示生成目标 内置变量$^表示所有依赖 内置变量$<表示 ...

  7. 《FPGA全程进阶---实战演练》第二章之焊接板子及调试注意事项

    1.若是读者第一次做板子,强烈建议画完PCB板后将PCB图打印出来,然后对照你买的芯片将芯片放置对 应的位置,然后查看所有的封装格式适不适合,否则等你做出板子来后再试,为时晚矣.笔者虽然知道要这么 做 ...

  8. 【转】7Z命令行解压缩

    7z.exe在CMD窗口的使用说明如下: 7-Zip (A) 4.57 Copyright (c) 1999-2007 Igor Pavlov 2007-12-06 Usage: 7za <co ...

  9. 常用命令——sed详解

    以下内容参考:http://qifuguang.me/2015/09/21/sed命令详解/ sed是stream editor的简称,也就是流编辑器.它一次处理一行内容,处理时,把当前处理的行存储在 ...

  10. 网络协议之ftp---ftp 协议详解

    http://blog.csdn.net/yxyhack/article/details/1826256 http://blog.chinaunix.net/uid-7777486-id-204393 ...