Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2017-04-19 23:35
711 查看
这个错误看起来很明显说的是这个注入的类是必须存在的,但是呢,这个注入的类不存在当然,我的项目中很明显存在我的项目是 spring spring MVC mybatis三个框架整合分4层控制层 XxxController 注解@Controller服务层 XxxService 注解 @Service持久层 XxxDao 注解 @Repository最后就是mybatis的mapper接口 注解为@Component关于这几个注解的含义,百度如下
看字面含义,很容易却别出其中三个: @Controller 控制层,就是我们的action层 @Service 业务逻辑层,就是我们的service或者manager层 @Repository 持久层,就是我们常说的DAO层 而@Component (字面意思就是组件),它在你确定不了事哪一个层的时候使用。 其实,这四个注解的效果都是一样的,spring都会把它们当做需要注入的Bean加载在上下文中; 但是在项目中,却建议你严格按照除Componen的其余三个注解的含义使用在项目中。这对分层结构的web架构很有好处!!百度了好久,没找到合适的就一次次实验发现是个摸不到头脑的的问题,为什么这样我也不知道就是把 mybatis的mapper接口的注解
@Component改成
@Repository
最后就可以了
相关文章推荐
- {@org.springframework.beans.factory.annotation.Autowired(required=true)}
- SSM整合单元测试出错@org.springframework.beans.factory.annotation.Autowired(required=true)}
- Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)
- @org.springframework.beans.factory.annotation.Autowired(required=true)
- Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
- @org.springframework.beans.factory.annotation.Autowired(required=true)
- 报错:Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
- springmcv 整合shiro报{@org.springframework.beans.factory.annotation.Autowired(required=true)}
- bug解决_{@org.springframework.beans.factory.annotation.Autowired(required=true)}
- @org.springframework.beans.factory.annotation.Autowired(required=true)
- Spring异常: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
- mapper注入失败问题解决 {@org.springframework.beans.factory.annotation.Autowired(required=true)}
- @org.springframework.beans.factory.annotation.Autowired(required=true)
- 异常:org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
- beans.factory.BeanCreationException beans.factory.annotation.Autowired(required=true)
- beans.factory.BeanCreationException beans.factory.annotation.Autowired(required=true)
- Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.Be
- "org.springframework.beans.factory.BeanNotOfRequiredTypeException……" 错误解决方案
- 解决: org.springframework.beans.factory.BeanNotOfRequiredTypeException