I replaced maven with gradle in the project. Previously, the application worked without any problems. Now using the gradle clean build command, the application throws a few errors regarding e.g. constructor or logger, nothing like this appeared when using maven. What could be the cause of this and possibly how to fix it?
Some example of errors:
error: variable itemService not initialized in the default constructor
private final ItemService itemService;
ItemController
@RequiredArgsConstructor
@RestController("GraphItemController")
@RequestMapping("/api/stats")
public class ItemController {
private final ItemService itemService;
@GetMapping
public ResponseEntity<List<ItemsByCategoryAndTypeStatisticDTO>> getItemsByCategoryAndTypeStatistic() {
List<ItemsByCategoryAndTypeStatisticDTO> itemsByCategoryAndTypeStatisticDTOs = itemService
.getItemsByCategoryAndTypeStatistic();
return new ResponseEntity<>(itemsByCategoryAndTypeStatisticDTOs, HttpStatus.OK);
}
}
ItemServiceImpl (error relates to logger)
error: cannot find symbol
log.info("Categories reading started");
^
symbol: variable log
location: class ItemServiceImpl
ItemServiceImpl
@Slf4j
@RequiredArgsConstructor
@Service("GraphItemServiceImpl")
public class ItemServiceImpl implements ItemService {
private final ItemRepository itemRepository;
private final TypeRepository typeRepository;
private final CurrentUser currentUser;
@Override
public List<ItemsByCategoryAndTypeStatisticDTO> getItemsByCategoryAndTypeStatistic() {
log.info("Categories reading started");
Map<String, ItemsByCategoryAndTypeStatisticDTO> byCategory = findByCategory();
Map<String, ItemsByCategoryAndTypeStatisticDTO> byCategoryAndType = findByCategoryAndType();
log.info("Categories reading completed");
if(byCategory.isEmpty()) {
return Collections.emptyList();
}
enterItemsNumberForTypeInRelatedCategoryDTO(byCategoryAndType, byCategory);
List<ItemsByCategoryAndTypeStatisticDTO> itemsByCategoryAndTypeStatisticDTOs = new ArrayList<>();
itemsByCategoryAndTypeStatisticDTOs.addAll(byCategory.values());
return itemsByCategoryAndTypeStatisticDTOs;
}
Or something like this even though the environment does not show anything in red, only when building.
itemByCategoryAndTypePairs.put(itemNumberByCategory.getAppaCategoryName(), itemNumberByCategory);
^
symbol: method getAppaCategoryName()
location: variable itemNumberByCategory of type ItemsByCategoryAndTypeStatisticDTO
ItemServiceImpl
private Map<String, ItemsByCategoryAndTypeStatisticDTO> convertListToMap(
List<ItemsByCategoryAndTypeStatisticDTO> itemsNumberByCategories) {
Map<String, ItemsByCategoryAndTypeStatisticDTO> itemByCategoryAndTypePairs = new TreeMap<>();
itemsNumberByCategories.forEach(itemNumberByCategory -> {
itemByCategoryAndTypePairs.put(itemNumberByCategory.getAppaCategoryName(), itemNumberByCategory);
});
return itemByCategoryAndTypePairs;
}