springboot的UnsatisfiedDependencyException异常问题
文章最前: 我是Octopus,这个名字来源于我的中文名--章鱼;我热爱编程、热爱算法、热爱开源。所有源码在我的个人github ;这博客是记录我学习的点点滴滴,如果您对 Python、Java、AI、算法有兴趣,可以关注我的动态,一起学习,共同进步。
相关文章:
- DuplicateKeyException异常处理:java向数据库插入数据异
- springboot的UnsatisfiedDependencyException异常问题
- org.springframework.dao.DataIntegrityViolationException
- com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'current_state'
- java中出现这种错误: "error": "Internal Server Error",
- The Tomcat connector configured to listen on port 8888 failed to start
- java.nio.charset.MalformedInputException错误解决
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.geekplus.dao
文章目录:
1.问题报错
2.问题描述:
3.解决问题:
1.问题报错
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.geekplus.hephaestus.wms.shelfscore.ShelfScoreTests2': Unsatisfied dependency expressed through field 'shelfScoreSyn'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.geekplus.hephaestus.wms.api.shelfscoring.ShelfScoreSyn' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2.问题描述:
遇到这个问题,首先提示Dependency annotations
package com.geekplus.hephaestus.wms.shelfscore;import com.geekplus.hephaestus.library.sys.AlgoSysConfigUtils;
import com.geekplus.hephaestus.wms.HephaestusWmsApiApplication;
import com.geekplus.hephaestus.wms.api.shelfscoring.ShelfScoreFacade;
import com.geekplus.hephaestus.wms.api.shelfscoring.ShelfScoreSyn;
import com.geekplus.hephaestus.wms.api.shelfscoring.entity.ShelfScoreResult;
import com.google.common.collect.ImmutableList;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner;import java.util.HashMap;
import java.util.List;
import java.util.Map;/**** @author: zhangyu*/@RunWith(SpringRunner.class)
@SpringBootTest(classes = {HephaestusWmsApiApplication.class}) // 指定启动类
@ComponentScan(basePackages = {"com.geekplus"})
public class ShelfScoreTests2 {@Beforepublic void prepare() {AlgoSysConfigUtils.setValue("hephaestus.debug.enabled", "true");}@Autowiredprivate ShelfScoreSyn shelfScoreSyn;@Testpublic void testUpdateShelfScore() {shelfScoreSyn.execute();}
}
里面引用了, private ShelfScoreSyn shelfScoreSyn;但是在另外一个类中:
package com.geekplus.hephaestus.wms.api.impl.shelfscoring;import com.geekplus.hephaestus.dataplatform.common.dao.rms.AthenaBaseShelfMapper;
import com.geekplus.hephaestus.dataplatform.common.dao.wms.BaseShelfMapper;
import com.geekplus.hephaestus.dataplatform.common.entity.rms.AthenaBaseShelf;
import com.geekplus.hephaestus.dataplatform.common.entity.wms.BaseShelf;
import com.geekplus.hephaestus.library.sys.AlgoSysConfigUtils;
import com.geekplus.hephaestus.wms.api.shelfscoring.ShelfScoreSyn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;/*** 将rms的货架数据同步到wms货架数据上**/
// @Service
public class ShelfScoreSynImpl implements ShelfScoreSyn {// 查询rms的货架数据同步到wms货架数据上@Autowiredprivate AthenaBaseShelfMapper athenaBaseShelfMapper;@Autowiredprivate BaseShelfMapper baseShelfMapper;@Overridepublic void execute() {/*1.从数据库查询货架位置信息2.把数据插入到wms3.返回插入的值*/List<AthenaBaseShelf> athenaBaseShelfList = athenaBaseShelfMapper.selectBaseShelf();Map<String, AthenaBaseShelf> athenaBaseShelfMap = athenaBaseShelfList.stream().collect(Collectors.toMap(AthenaBaseShelf::getShelfCode, e -> e));List<BaseShelf> baseShelfList = baseShelfMapper.selectWmsBaseShelf();List<BaseShelf> updatedBaseShelfList = updateBaseShelf(athenaBaseShelfMap, baseShelfList);for (BaseShelf baseShelf : updatedBaseShelfList) {System.out.println(baseShelf);}}private List<BaseShelf> updateBaseShelf(Map<String, AthenaBaseShelf> athenaBaseShelfMap, List<BaseShelf> baseShelfList) {int shiftParameter = AlgoSysConfigUtils.getIntegerValue("hephaestus.shelfscoring.shiftParameter", 1000);for (BaseShelf baseShelf : baseShelfList) {if (athenaBaseShelfMap.keySet().contains(baseShelf.getShelfCode())) {AthenaBaseShelf athenaBaseShelf = athenaBaseShelfMap.get(baseShelf.getShelfCode());if (athenaBaseShelf.getLocationX() != null || athenaBaseShelf.getLocationY() != null || athenaBaseShelf.getLocationX() > 0 || athenaBaseShelf.getLocationY() > 0) {int shiftLocationX = athenaBaseShelf.getLocationX() * shiftParameter;int shiftLocationY = athenaBaseShelf.getLocationY() * shiftParameter;if (!(baseShelf.getLocax() == shiftLocationX && baseShelf.getLocay() == shiftLocationY)) {baseShelf.setLocax(shiftLocationX);baseShelf.setLocay(shiftLocationY);baseShelfMapper.updateWmsBaseShelf(baseShelf);}}}}return baseShelfList;}
}
3.解决问题:
它没有交给spring进行管理:ShelfScoreSynImpl ,在上面加个注释就好了,把它交给spring管理。
当加了@service之后,就没有这种异常了。
springboot的UnsatisfiedDependencyException异常问题相关推荐
- springboot启动总是启动不起来UnsatisfiedDependencyException异常
springboot启动总是启动不起来UnsatisfiedDependencyException异常 参考文章: (1)springboot启动总是启动不起来UnsatisfiedDependenc ...
- 小编教您Springboot项目中异常拦截设计与处理
项目运行过程中会出现各种各样的问题,常见的有以下几种情况: 业务流程分析疏漏,对业务流程的反向操作.边界分析设计不充分 调用外部服务.调用外部系统出现的超时.错误.返回值与预期不符 外部资源连通性问题 ...
- springboot mybatis常见异常及处理方法
springboot mybatis常见异常及处理方法 参考文章: (1)springboot mybatis常见异常及处理方法 (2)https://www.cnblogs.com/gunduzi/ ...
- springboot集成mongoDB 异常认证
springboot集成mongoDB 异常认证 参考文章: (1)springboot集成mongoDB 异常认证 (2)https://www.cnblogs.com/mh-study/p/980 ...
- SpringBoot(6) SpringBoot配置全局异常
SpringBoot(6) SpringBoot配置全局异常 参考文章: (1)SpringBoot(6) SpringBoot配置全局异常 (2)https://www.cnblogs.com/pl ...
- SpringBoot使用MongoDB异常问题
SpringBoot使用MongoDB异常问题 参考文章: (1)SpringBoot使用MongoDB异常问题 (2)https://www.cnblogs.com/linzhanfly/p/967 ...
- 已解决org.springframework.beans.factory.UnsatisfiedDependencyException异常的正确解决方法,亲测有效!!!
已解决org.springframework.beans.factory.UnsatisfiedDependencyException异常的正确解决方法,亲测有效!!! 文章目录 报错问题 解决方法 ...
- SpringBoot 自定义全局异常处理器
SpringBoot自定义全局异常处理器 一.maven依赖 二.GlobalExceptionHandler.java 三.ResponseStandard.java 四.logback.xml 五 ...
- SpringBoot配置全局异常捕获
SpringBoot中自带的异常捕获机制返回的默认页面比较丑,对用户来说不够人性化.所以这篇文章来讲解SpringBoot钟自定义全局异常捕获. 本文的源码已经上传GitHub:https://git ...
- Springboot捕获全局异常:MethodArgumentNotValidException
Springboot捕获全局异常:MethodArgumentNotValidException 控制器 方法上添加@Valid注解 @PostMapping("/update") ...
最新文章
- HDU 2586 How far away ? LCA ---tanjar+并查集 离线算法
- fzu 2150 Fire Game 【身手BFS】
- java新特性对数组的支持
- MyBatis映射文件(一)
- 腾讯产品面试题 | 如何把剃须刀卖给张飞?
- jps查看java进程以及pwdx通过pid查看进程所在位置
- Erlang与java的内存架构比较
- 网络安装centos5.4
- [ 2022年4月8日更新 ]Typecho Handsome主题美化教程
- XmlHelpers
- 如何通过自定义属性设置PDMS模型颜色
- 人脸识别相似度计算方法
- java WinRM 远程连接 windows10 执行脚本
- 愿你和我一样喜欢蛋炒饭
- Google 以图搜图 - 相似图片搜索原理 - Java实现
- 电话号码正则表达式手机固话分机
- docker(三)docker仓库
- 2021-01-11小米随身wifi网络创建总是失败是什么问题?
- vue3组合式api
- 最近一百年,全球涌现过哪些最顶尖的、最赚钱的公司?
热门文章
- java transaction 包,在Java中,实现用户界面功能的包是A.java.appletB.java.transactionC...
- 关于社交小技巧,一篇老文章,与大家分享
- 2006百度之星程序设计竞赛初赛(转)
- IDEA下,工程突然找不到或引用不到jar包。。
- 目标检测中算法评价指标FPS和mAp的原理和代码实现
- Husky数据分析——全球航班信息的研究
- 知识点16--k8s资源配置清单入门
- 【计算机毕业设计】074智能物流管理系统
- 多商户商城系统功能拆解32讲-平台端营销-限时秒杀
- C语言 选择结构 if二选一