V
V
vitya_brodov2021-08-16 20:34:23
Spring
vitya_brodov, 2021-08-16 20:34:23

Why is the class not building?

Hello!
when using Lombok, it works somehow crookedly (maybe)
for example, the class is not built: ErrorDto class
611aa0bf244d5625501425.png

:

@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ErrorDto {
    private String error;

    @JsonProperty("error_description")
    private String description;
}


Controller:

@RequiredArgsConstructor
@Controller
public class CustomErrorController implements ErrorController {

    private static final String PATH = "/error";

    ErrorAttributes errorAttributes;

    @RequestMapping(PATH)
    public ResponseEntity<ErrorDto> error(WebRequest webRequest){

        Map<String, Object> attributes = errorAttributes.getErrorAttributes(
                webRequest,
                ErrorAttributeOptions.of(ErrorAttributeOptions.Include.EXCEPTION, ErrorAttributeOptions.Include.MESSAGE)
                );

        // здесь вбрасывает ошибку
        return ResponseEntity
                .status((Integer) attributes.get("status"))
                .body(ErrorDto.builder()
                        .error((String) attributes.get("status"))
                        .description((String) attributes.get("status"))
                        .build()
                );

    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2021-08-17
@vitya_brodov

Good afternoon!
Usually, this problem occurs for two reasons:
1) there is no lombok plugin - https://projectlombok.org/setup/intellij
2) annotation processing is not enabled - https://www.jetbrains.com/help/idea/annotation-pro ...
Let me know if the above tips don't help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question