Maven编译器插件看不到Lombok的注释

MrF*_*man 5 java spring maven lombok maven-compiler-plugin

在我的应用程序中,我有 3 个这样的模块:

permissions (parent pom)
|---permission-api (just api, without main spring class)
|---permission-service (spring boot app)
Run Code Online (Sandbox Code Playgroud)

在主模块的父pom中,我有pom,其中包含:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.3</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
    <module>permissions-api</module>
    <module>permissions-service</module>
</modules>
Run Code Online (Sandbox Code Playgroud)

和一些依赖项。现在我想用 Maven clean install 构建我的整个项目。Permission-api模块已构建(lombok注释没有问题)。在 pom 中,对 lombok 的唯一引用是:

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>
Run Code Online (Sandbox Code Playgroud)

无论如何,当我尝试仅构建权限服务或整个项目时,我遇到了如下编译错误:

cannot find symbol
[ERROR]   symbol:   method getPermissionsList()
[ERROR]   location: variable employee of type permissions.model.entity.Employee
Run Code Online (Sandbox Code Playgroud)

我知道我应该将 maven-compiler-plugin 添加到 pom.xml (我也尝试将其添加到父 pom 中),我这样做了,但没有帮助:

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>
Run Code Online (Sandbox Code Playgroud)

你能告诉我我做错了什么吗?

Aug*_*tto 1

依赖关系,如在projectlombok.org中,应该在“provided”范围内,这意味着它仅在编译时需要,但在运行时不需要:

<dependencies>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.22</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

这应该足够了。