Variable might not have been initialized when I'm using @RequiredArgsConstructor

8 java intellij-idea lombok spring-boot

I'm learning about Lombok and I have this error: Variable productRespository might not have been initialized. But I have the @RequiredArgsConstructor. And I'm using Intellij idea. So why do I need to create a constructor if I'm using this annotation? Thank you!

import lombok.RequiredArgsConstructor;

    @RequiredArgsConstructor

    @Service
    public class ProductService {

        private final ProductRespository productRespository;

        ...
    }
Run Code Online (Sandbox Code Playgroud)

小智 17

如果尚未安装 lombok 插件,则需要安装它。