天天看点

expected at least 1 bean which qualifies as autowire candidate for this ***错误的分析

出现expected at least 1 bean which qualifies as autowire candidate for this ***错误的时候,首先你确实就要检查一下你的spring配置文件,从项目驱动时web.xml一直检查到对应驱动的各种配置文件例如ApplicationContext.xml、Spring MVC.xml等配置文件。

仔细检查配置文件加载成功否?

如果出现mapper加载未成功,需查看web.xml中配置文件

<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:spring/applicationContext*.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
           

加载配置文件有没有成功加载dao项目层的配置文件成功(应用层的实现类没有实现对应的接口)

如果对应接口加载成功检查是否注解书写错误,到时spring不能进行注入等问题。