即使我从我的代码异常中抛出自定义异常,我也收到了邮递员内部服务器错误。我想查看我抛出的具有有效错误消息和错误代码的异常。如果你们中的任何人能在这一点上帮助我,那将是一个很大的帮助。就像我如何获得更好的错误消息一样。添加以下代码快照。提前致谢。
@Service
public class FetchActionImpl implements FetchAction {
private static Logger log = LoggerFactory.getLogger(FetchActionImpl.class);
@Autowired
FetchActionServiceImpl fetchActionService;// = new FetchActionServiceImpl();
@Override
public FetchResponse fetchActionRequest(String caseId) throws BBWException,Exception{
//String resp ="";
log.info("fetchaction Request: {}",ApplicationConstants.LOG_ENTRY_MESSAGE);
log.info("The caseId received from BRASS:\n {}",caseId);
FetchResponse resp = null;
try{
if(true) {
throw new BBWException("500","Test");
}
resp = fetchActionService.fetchIt(caseId);
log.debug("fetchaction Response: {}",resp.toString());
}
catch (BBWException be) {
throw be;
}
catch (Exception e) {
throw new BBWException("500",e.getMessage());
}
return resp;
}
}
@Api
@Path("/fetch_service")
public interface …
Run Code Online (Sandbox Code Playgroud) 我对这些注释有点困惑,因为我对 Spring 很陌生。我试图在谷歌上找到它并找到了很多答案,但仍然没有弄清楚。我开始知道@Component 是@Repository、@Service 和@Controller 的超级注释,但我仍然怀疑何时使用@Component 以及何时使用@ComponentScan 谁能帮我清楚地了解这两者注释,以及两者的区别。