springmvc报错

xzdwskws 2018-06-05 03:48:18
3个文件,web.xml,applicationContext.xml,springmvc.xml,现在启动报错
严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.xebest.service.XeUserTypeService com.xebest.controller.HomeController.xeUserTypeService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xeUserTypeServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.xebest.mapper.XeUserTypeReadMapper com.xebest.service.serviceImpl.XeUserTypeServiceImpl.xeUserTypeReadMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.xebest.mapper.XeUserTypeReadMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
a
...全文
917 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
诺丽果 2018-06-07
  • 打赏
  • 举报
回复
如果按照四楼的配置,暂时是可以了,要是你以后增加一个Mapper,你的配置文件就得跟着改了,不如用springmvc的自动扫描包,这样:
	<!-- 自动扫描所有的Mapper接口与文件 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.xebest.mapper"></property>
	</bean>
,你试试
脾气太臭 2018-06-05
  • 打赏
  • 举报
回复
没有为依赖项找到[com.xebest.mapper.XeUserTypeReadMapper] 类型的匹配bean 看一下是不是mapper.xml的问题
xzdwskws 2018-06-05
  • 打赏
  • 举报
回复
恩可以了多谢啊
Cathy313 2018-06-05
  • 打赏
  • 举报
回复
NoSuchBeanDefinitionException: No matching bean of type [com.xebest.mapper.XeUserTypeReadMapper] applicationContext.xml少一个东西,你添加一下:

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
		p:basePackage="com.xebest.mapper.XeUserTypeReadMapper" 
p:sqlSessionFactoryBeanName="sqlSessionFactory" />
如果你用不了这种表达,换成:

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.xebest.mapper.XeUserTypeReadMapper"/>
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
	</bean>
我这边手打的,没有测试,你根据你自己的情况改一下
xzdwskws 2018-06-05
  • 打赏
  • 举报
回复
xzdwskws 2018-06-05
  • 打赏
  • 举报
回复
xzdwskws 2018-06-05
  • 打赏
  • 举报
回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧