gpt4 book ai didi

java - 找不到依赖项 : expected at least 1 bean 的 [HrEmployeesReportOutput] 类型的合格 bean

转载 作者:行者123 更新时间:2023-12-02 09:18:43 24 4
gpt4 key购买 nike

尝试运行 springboot 应用程序时出现以下错误,我无法使用 @Autowired 注解注入(inject) 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 接口(interface)如果您使用 @ComponentScan (如果您使用 spring-boot,则自动添加),您的类必须具有注释 @Component

例如:

@Component
公共(public)类 HrEmployeesReportOutputImpl 实现 HrEmployeesReportOutput{...}

关于java - 找不到依赖项 : expected at least 1 bean 的 [HrEmployeesReportOutput] 类型的合格 bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58841029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com