繁体   English   中英

无法使用 Eclipse 在 Java 中解决 PMD 错误

[英]PMD errors unable to resolve in java using eclipse

我在 eclipse 中创建了一个下面的 java 服务,并使用 PMD 插件查看了代码我遇到了以下错误

** 错误 **

DataflowAnomalyAnalysis: Found 'DD'-anomaly for variable 'result' (lines '80'-'83').
SignatureDeclareThrowsException: A method/constructor should not explicitly throw java.lang.Exception

服务

@GetMapping("OCR/GetBarcodeRead")
    @ApiOperation("Get result from Barcode Zxing library")
    public String getBarcodeRead() throws Exception {

        String result = new String();

        try {
            result = service.zxing();
        } catch (Exception e) {
            System.out.println(e);
            result = "";

        }

        return result;

    }

有人可以帮我解决这个问题吗? 提前致谢

你的方法声明你抛出Exception ,但你不是,所以删除它

public String getBarcodeRead() {

同时删除new String()并用""初始化它

String result = "";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM