maven 无法识别选项mapstruct. defaultmodelentModel

ttisahbt  于 12个月前  发布在  Maven
关注(0)|答案(1)|浏览(146)

我在pom.xml文件中有这样的配置:

<properties>
        <java.version>11</java.version>
        <org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
<!-- more pom code -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <dependency>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>0.2.0</version>
                        </dependency>
                        <path>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                            <version>2.6.6</version>
                        </path>
                    </annotationProcessorPaths>
                    <compilerArgs>
                        <arg>
                            -Amapstruct.defaultComponentModel=spring
                        </arg>
                    </compilerArgs>
                </configuration>
            </plugin>

字符串
但我仍然在构建java: The following options were not recognized by any processor: '[mapstruct.defaultComponentModel]'时收到警告
我相信我的配置遵循Mapstruct documentation
为什么该选项不被认可?
This question似乎没有帮助

eufgjt7s

eufgjt7s1#

这个警告可以安全地忽略:你可以通过一个简单的配置标签并在里面添加一个默认配置文件来管理不再显示这个错误,比如:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <executions>
        <execution>
            <id>default-compile</id>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${mapstruct.version}</version>
                    </path>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </path>
                    <dependency>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-mapstruct-binding</artifactId>
                        <version>0.2.0</version>
                    </dependency>
                </annotationProcessorPaths>
                <compilerArgs>
                    <compilerArg>
                        -Amapstruct.defaultComponentModel=spring
                    </compilerArg>
                </compilerArgs>
            </configuration>
        </execution>
    </executions>
</plugin>

字符串
但是在测试的时候你会遇到另一个问题,有些Map器在没有maven的package stage的情况下是无法实现的。

相关问题