2 sonofbaba sonofbaba 于 2017.09.13 19:17 提问

maven下ssm问题 老是报错

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.guigu.crud.test.MapperTest': Unsatisfied dependency expressed through field 'departmentMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.guigu.crud.dao.DepartmentMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:386)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.guigu.crud.dao.DepartmentMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 28 more

老是报这个错

1个回答

Mr_Huang_ning
Mr_Huang_ning   2017.09.14 11:34

创建bean失败,注入也失败,你在用maven的时候是需要install的,你加了新的类或者方法就要install一下,在run里面有install。启动前要install

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
JFreeChart与struts框架冲突解决
在JAVA EE课程设计“图书馆推荐系统”中,需要制作柱状图和饼状图等将数据库的信息进行统计。从而发现了一些bug,特写此篇。 1、gnujaxp.jar包与struts冲突,gnujaxp.jar早JRE1.3以前的版本才需要,因此直接删掉即可。 2、因为JFreeChart是用servlet写的,因此需要配置文件。在web.xml中同时配置了核心过滤器,结果struts将servlet拦截,使
ssm maven项目整合出现的问题
异常 java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException 当时根据网上的博客来架构ssm项目出现了这个异常,问题原因是少了jackson的jar所导致,在pom.xml中加上 <dependency> <groupId>com.fast
使用SSM+Maven搭建项目框架常见问题及解决方法
使用SSM+Maven框架搭建完成后,可以写一个测试Demo测试框架有没有出现各种小问题,这里就以一个分页查询Demo为例测试框架。 1. Error creating bean with name 'XXXXX': Injection of autowired dependencies failed; nested exception is org.springframework.beans.
Maven+SSM框架下项目开发常见异常及解决方案(二)
1.Servlet.service() for servlet [SpringMVC] in context with path [/biglovewj] threw exception [Request processing failed; nested exception is org.apache.ibatis.builder.IncompleteElementException: Coul
Junit测试maven+ssm项目的过程及出现的错误总结
junit进行单元测试通常有两种:1. 不使用spring封装的junit,手动加载package com.puhua.test;import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.contex
maven导入ssm(springmvc spring mybatis)项目环境遇到的问题
最近在eclipse中使用maven来写ssm。 在maven中, 添加ssm的相关jar包只需要在pom.xml的标签中添加相应的依赖jar包就行了,确实非常方便。 但偶尔使用maven时也会遇到jar下载完毕,却项目在Tomcat中不能运行。 我再三确认,我编写的源文件时没有问题的。 有时同一个项目的代码,在A电脑上可以编译运行,在B电脑上却不能编译运行。 我这时就
Maven+SSM框架下项目开发常见异常及解决方案(一)
Caused by: Java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor 原因:缺少此包aopalliance-1.0.jar –这个jar包是spring的AOP,里面有Interceptor和Invocation 解决方法:下载并导入该jar包后方可解决 pom.xml: <depende
SSM后台系统
ssm学习资料,maven,ssm学习资料,maven,ssm学习资料,maven,ssm学习资料,maven,
SSM创建MavenProject后,index.jsp报错
时隔一年,重新拾起Java。记录学习中遇到的点点滴滴。
SSM框架整合后Tomcat正常启动,控制台未报错,访问所有页面均报404异常,总结
最近整合了ssm框架,今天想完善一下,遇到Tomcat正常启动,控制台也正常并未报错,但访问均报404异常 404异常,很常见,大多情况是路径错误、web.xml文件映射路径写错、服务器设置、servlet的jar包未导进去或者没有随项目发布等等。 如果是路径错误,仔细检查即可解决问题。 不过我遇到的都不是这一类,所以查了好久,也乘此总结一下,利人也利己。 1、 查看访问地址url有无打错