【出现错误的背景】

在使用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. 【WPF/WAF】界面布局(View)文件的多层嵌套(Nest)

    碎碎念:使用的是略冷门的Window Application Foundation(WAF)框架,搜到的都是WPF的UserControl用户控件的用法,实在蛋疼. 需求:主界面ShellWindow ...

  2. [sz,rz]使用sz/rz在两台Linux设备之间传输数据

    转自:https://superuser.com/questions/604055/using-rz-and-sz-under-linux-shell zsend #!/bin/sh DEV=/dev ...

  3. Spark读取文件

    spark默认读取的是hdfs上的文件. 如果读取本地文件,则需要加file:///usr/local/spark/README.md. (测试时候发现,本地文件必须在spark的安装路径内部或者平行 ...

  4. Spark Streaming中的操作函数讲解

    Spark Streaming中的操作函数讲解 根据根据Spark官方文档中的描述,在Spark Streaming应用中,一个DStream对象可以调用多种操作,主要分为以下几类 Transform ...

  5. 正确配置Linux系统ulimit值的方法

    在Linux下面部署应用的时候,有时候会遇上Socket/File: Can’t open so many files的问题:这个值也会影响服务器的最大并发数,其实Linux是有文件句柄限制的,而且L ...

  6. Game publishing request was abnormally terminated (ID 27492).

    本地可以正常发布:远程发布报错.怀疑跟直接删除数据库记录有关,wp_myarcadegames/wp_posts Game publishing request was abnormally term ...

  7. Windows消息队列一

    系统消息--ID范围 -0x03FF 由系统定义好的小哦啊拍下哦,可以在程序中直接使用. 用户自定义消息--ID范围0x0400-0x7FFF 由用户自己定义,满足用户自己的需求.由用户自己发出消息, ...

  8. (五)Qt实现自定义模型基于QAbstractItemModel

    一个小例子 QTableView + QStandardItemModel QStandardItemModel model; //设置大小 model.setColumnCount(); //列 m ...

  9. 关于Cocos2d-x中UI按钮的定义

    1.要有两张不同状态的图片 2.定义一个MenuItemSprite的实例,把这两张图的Sprite实例放进MenuItemSprite的实例 3.把MenuItemSprite的实例放进Menu实例 ...

  10. vlc player验证交换机igmp

    使用vlc media player发送多播数据,验证交换机igmp的设置是否成功. 链接 http://peakdrive.com/?p=440 http://www.dasblinkenlicht ...