admin管理员组

文章数量:1352974

I'm working on a demo project to practice microservices and their communication. I have already several microservices and I noticed hard to manage some common configuration and dependencies. So tried to gather common dependecies like lombok, object mapper and mapstruct etc in common package. Also, I thought it made sense if I gathered their annotation processors.

But I had a issue maven install when done that. Programmatically, I had no issue and my services were up without any issue. But when I tried to mvn clean compile the service which depended on common dependency I created it couldn't find the some enum in common package and said that error:

not found in package message

To solve it, I needed to add lombok, mapstruct and their processors in each service which used them.

That s okay for me. I think the reason is the processors but i couldn't understand why i can't do that. I don't even know what i should research for this. Could you enlighten me about this?

And, that s my case with pom files:

one of common:

<dependencies>
<!--    some other dependencies without any issue   -->
    <dependency>
        <groupId>.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
        <version>${mapstruct.version}</version>
    </dependency>
    <dependency>
        <groupId>.mapstruct</groupId>
        <artifactId>mapstruct-processor</artifactId>
        <version>${mapstruct.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </path>
                    <path>
                        <groupId>.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${mapstruct.version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
        <plugin>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

one of other services which use common:

<dependency>
    <groupId>com.order.management</groupId>
    <artifactId>common</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

本文标签: mavenImporting lombok and its annotation processor from custom dependencyStack Overflow