HrEmployeesReportOutput

HrEmployeesReportOutput

尝试运行springboot应用程序时出现以下错误,我无法使用@Autowired批注注入HrEmployeesReportOutput类,但尝试了其他方法,但没有起作用。

您能帮我吗?

No qualifying bean of type [com.nearshoretechnology.focalpoint.interactors.hremployees.HrEmployeesReportOutput] 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)}



@Controller
@RequestMapping("/management/hr/employees/report")
public class HrManagerEmployeeReportController {

    @Autowired
    private HrEmployeesReportOutput hrEmployeesReportPresenter;

    private HrEmployeesReportInput hrReportEmployees;

    @Secured({ HR_ADMIN, BENCH_ADMIN })
    @RequestMapping(method = RequestMethod.GET)
    public String index(Model model) {
        HrEmployeesReportForm form = new HrEmployeesReportForm();
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
        form.setUsername(username);

        this.hrReportEmployees.setReportEmployeesPresenter(hrEmployeesReportPresenter);

        model.addAllAttributes(hrReportEmployees.employeeReport(form));

        return "management/hr/reports/employees";
    }

}




public interface HrEmployeesReportOutput extends InteractorOutput<HrEmployeesReportResult> {

}


public interface InteractorOutput<T> {

  Map<String, Object> generateViewModel(T result);
}


public class HrEmployeesReportResult extends BaseResult {}



public class BaseResult {}



public interface HrEmployeesReportInput {


    Map<String, Object> employeeReport(HrEmployeesReportForm form);

    void setReportEmployeesPresenter(HrEmployeesReportOutput presenter);



}

最佳答案

您应该至少有一个实现HrEmployeesReportOutput接口的类
如果使用的是@ComponentScan(如果使用的是Spring-boot,则会自动添加),您的类必须具有注释@Component

例如:

@Componentpublic class HrEmployeesReportOutputImpl implements HrEmployeesReportOutput{...}

07-26 04:44