简体   繁体   English

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

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

I have created a below java service in eclipse and reviewed the code using PMD plugin I'm getting below errors我在 eclipse 中创建了一个下面的 java 服务,并使用 PMD 插件查看了代码我遇到了以下错误

** Errors ** ** 错误 **

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

java service服务

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

    }

Could someone help me to resolve this issue?有人可以帮我解决这个问题吗? Thanks in advance提前致谢

Your method declaring you throwing Exception , but you aren't, so remove it你的方法声明你抛出Exception ,但你不是,所以删除它

public String getBarcodeRead() {

Also remove new String() and initialize it with ""同时删除new String()并用""初始化它

String result = "";

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

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