public class CommonCode { private IntPatientService intPatientService; private PutPeisPatientMapper putPeisPatientMapper;
单独使用时报错,调试发现IntPatientService 是null。
之后
CommonCode CommonCode1=new CommonCode();发现还是null
依照IDEA提示,
public class CommonCode { private IntPatientService intPatientService; private PutPeisPatientMapper putPeisPatientMapper; public CommonCode(IntPatientService intPatientService, PutPeisPatientMapper putPeisPatientMapper) { this.intPatientService = intPatientService; this.putPeisPatientMapper = putPeisPatientMapper; }
创建PutPeisPatientMapper 的传递,
CommonCode CommonCode1=new CommonCode(intPatientService, putPeisPatientMapper);
结论:
1、IDEA很智能
2、要充分理解初始化对象,报错都是因为没有初始化,造成使用时是null