拥抱开源,分享知识,欢迎来到我的小世界|

夏·舍

园龄:3年7个月粉丝:32关注:16

springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration. 报错Consider defining a bean of type

报错如图:

APPLICATION FAILED TO START 
Description : 
Parameter 2 of constructor in com.javasm.service.impl . sales. SalesOrderItemsServiceImp1 required a bean of type 
' com.javasm.domin . vo. sales . SalesGoodsVO ' 
that could not be found. 
Action : 
Consider defining a bean of type 
' com.javasm.domin . vo. sales . SalesGoodsVO ' 
in your configuration .

 

解决办法:

其实就是声明的变量没有被springboot注入容器 如图三个变量均进行了声明,均使用了@RequiredArgsConstructor+private final 但VO类其实没能注入容器

-@RequiredArgsConstructor//*0 
@Transactiona1 
- @Service 
public class SalesOrderItemsServiceImp1 extends BaseServiceimp1<Sa1esl 
private final SalesOrderItemsMapper salesOrderItemsMapper; 
private final SalesOrderItemsTransfer salesOrderItemsTransfer; 
private final SalesGoodsVO salesGoodsVO;

 

查看mapper接口,被springboot启动类上的注解以包扫描的形式注入了容器,所以没问题

3@SpringBootApp1ication 
@mapperScan(basePackages 
.com . mapper " 
@Enab1eTransactionmanagement// 
//@Enab1eSchedu1ing/,/ff,É'f-%%ißE 
public class ProjectApp1ication {

 

查看transfer类,被@Component注解声明,所以也没问题

- @Component 
- @RequiredArgsConstructor 
public class SalesOrderItemsTransfer extends Be

 

查看salesGoodsVO类,既没有包扫描,又没有@component注解,自然就报错了

解决办法 要么加上@component,要么自己new对象

private SalesGoodsVO salesGoodsVO 
new SalesGoodsVO();

本文作者:夏·舍

本文链接:https://www.cnblogs.com/BRSblackshoot/p/15367699.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   夏·舍  阅读(2598)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起