service的bean无法注入,什么原因?

来源:2-6 逐层完成SSM的各项配置

幕布斯8047256

2019-07-24

Error creating bean with name ‘areaController’: Unsatisfied dependency expressed through field ‘areaService’;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.lijiang.o2o.service.AreaService’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

图片描述
图片描述
图片描述
图片描述
图片描述
图片描述

写回答

3回答

枳飨詠逺相守0

2020-03-06

解决了吗????我也是这样的问题。AreaService的bean总是失败,AreaDao没问题

//img1.sycdn.imooc.com/szimg/5e6122a1095d9fa402880189.jpg

//img1.sycdn.imooc.com/szimg/5e6122b509a867f905600256.jpg

//img.mukewang.com/szimg/5e6122d009b265fb05880174.jpg//img1.sycdn.imooc.com/szimg/5e6122f7091d0a1704730218.jpg


java.lang.IllegalStateException: Failed to load ApplicationContext

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shopServiceImpl' defined in file [/Users/apple/IdeaProjects/myo2o/target/classes/com/harry/o2o/service/impl/ShopServiceImpl.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException

Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException


1
2
枳飨詠逺相守0
回复
翔仔
回复 翔仔谢谢老师,确实是这个jar包的问题
2020-03-06
共2条回复

翔仔

2019-07-25

同学好,首先可以尝试右键tomcat server 然后 clean 看看;如果不行,在还没有解决类似问题的能力之前,还是和视频里一样的配置,spring-service.xml里

<context:component-scan base-package="com.imooc.o2o.service" />

到service而不是到impl

其次,

serviceimpl里直接

@Service
public class AreaServiceImpl implements AreaService {

即可

0
2
翔仔
回复
幕布斯8047256
现在还出现这样的问题吗,程序说1是1,不可能大家的可以同学的不行,肯定还是哪里配错了,可以再重新和视频一模一样配置一次
2019-07-25
共2条回复

Sivel

2019-07-24

截图发出来

0
6
Sivel
回复
幕布斯8047256
784511652 加我qq
2019-07-25
共6条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程