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);
最后修改:2021 年 02 月 08 日
如果觉得我的文章对你有用,请随意赞赏