控制器中构造函数的参数0需要另一个包中类型为仓库类的Bean

问题描述

尽管我在pom.xml中添加了包含我的GemDaoImpl存储库类的软件包,但它给出了错误

Parameter 0 of constructor in com.bfm.accounting.portfolio.controller.PortfolioApiController required a bean of type 'com.bfm.app.reporting.gem.dao.impl.GemDaoImpl' that Could not be found.
    
Action:

Consider defining a bean of type 'com.bfm.app.reporting.gem.dao.impl.GemDaoImpl' in your configuration.

能帮我解决这个错误吗?

解决方法

尝试在XML的component-scan元素中提及包含GemDaoImpl的软件包

public class TestShape {
    public static void main(String[] args){
        Shape s1 = new Circle(2.0);
        System.out.println(s1.getCircumference());
    }
}

或者如果您使用的是基于类的配置,请使用

<context:component-scan base-package="com.mkyong.customer" />