java.lang.InstantiationException
Caused by: java.lang.NoSuchMethodException
在实体类中添加构造无参函数
原代码:
String className = "com.snail4cloud.snail.rights.service.impl.insure.InsureOrderServiceImpl";
RightsActiveService rightsActiveService = (RightsActiveService) Class.forName(className).newInstance();
rightsActiveService.rightsActive(receiveRightsBag.getUserId(), receiveRightsBag.getRightsOrderId(), receiveRights);
public interface RightsActiveService {
R rightsActive(String userId, String rightsOrderId, ReceiveRights receiveRights);
}
@AllArgsConstructor
public class InsureOrderServiceImpl extends CrudServiceImpl<InsureOrderMapper, InsureOrder> implements InsureOrderService, RightsActiveService {
private final InsureRightsService insureRightsService;
private final UserInfoService<UserInfo> userInfoService;
@Override
public R<?> rightsActive(String userId, String rightsOrderId, ReceiveRights receiveRights) {
return activateInsure(userId, rightsOrderId, receiveRights);
}
}
修改后:
String className = "insureOrderServiceImpl";
RightsActiveService rightsActiveService = SpringContextHolder.getBean(className);