Update:
tried key="#p0" , does not work
Trying to implement Redis with spring boot to cache my products, but I faced the problem, appreciate for any help
java.lang.IllegalArgumentException: Null key returned for cache operation (maybe you are using named params on classes without debug info?)
Controller
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/api/products")
public class ProductController {
@Autowired
ProductService productService;
@GetMapping("/")
public ResponseEntity<?> getAll() {
List<Product> products = productService.findAll();
return ResponseEntity.ok(products);
}
}
Service
@Cacheable(value = "product", key = "#productId")
public List<Product> findAll() {
return productRepository.findAll();
}
@EnableCaching annotation has also been put in the main class