尝试运行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
例如:
@Component public class HrEmployeesReportOutputImpl implements HrEmployeesReportOutput{...}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句