Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4806

I can't access Lombok's AllArgsContructor when I extend RepresentationModelAssemblerSupport

$
0
0

I've been trying to solve it for a while but I couldn't find anything to help me, in my Spring Boot Project, in one of the assembler classes I extend "RepresentationModelAssemblerSupport", when I extend the class I start to have a conflict with my Lombok @AllArgsContructor, I use it to not use @Autowired keeping the code clean, so I can't compile, and I get the following Warning in the annotation "Lombok needs a default constructor in the base class", but I already have a constructor in the Class

After a lot of research, I saw that in some cases other annotations like @NoArgsConstructor and @RequiredArgsConstructor helped but I was not successful.

@Component@AllArgsConstructorpublic class SaleModelAssembler        extends RepresentationModelAssemblerSupport<Sale, SaleModel> {    @Autowired    private ModelMapper modelMapper;enter image description here    public SaleModelAssembler() {        super(SaleResource.class, SaleModel.class);    }    @Override    public SaleModel toModel(Sale sale) {        SaleModel saleModel = createModelWithId(sale.getCode(), sale);        modelMapper.map(sale, saleModel);        saleModel.getItems().forEach(saleItemModel -> {            saleItemModel.getProduct().add(linkTo(ProductResource.class)                    .slash(saleItemModel.getProduct().getId()).withSelfRel());        });        return saleModel;    }    @Override    public CollectionModel<SaleModel> toCollectionModel(Iterable<? extends Sale> entities) {        return super.toCollectionModel(entities).add(linkTo(SaleResource.class).withSelfRel());    }}

Imagem erro


Viewing all articles
Browse latest Browse all 4806

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>