小编Man*_*tel的帖子

如何获取特定错误而不是内部服务器错误?

即使我从我的代码异常中抛出自定义异常,我也收到了邮递员内部服务器错误。我想查看我抛出的具有有效错误消息和错误代码的异常。如果你们中的任何人能在这一点上帮助我,那将是一个很大的帮助。就像我如何获得更好的错误消息一样。添加以下代码快照。提前致谢。

@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)

java rest web-services spring-boot java-ee-8

5
推荐指数
1
解决办法
9521
查看次数

Component-Scan 和 @Component 之间的区别?

我对这些注释有点困惑,因为我对 Spring 很陌生。我试图在谷歌上找到它并找到了很多答案,但仍然没有弄清楚。我开始知道@Component 是@Repository、@Service 和@Controller 的超级注释,但我仍然怀疑何时使用@Component 以及何时使用@ComponentScan 谁能帮我清楚地了解这两者注释,以及两者的区别。

spring annotations

1
推荐指数
1
解决办法
9236
查看次数

标签 统计

annotations ×1

java ×1

java-ee-8 ×1

rest ×1

spring ×1

spring-boot ×1

web-services ×1