【问题标题】:Unable to parse configuration of MapStruct plugin无法解析 MapStruct 插件的配置
【发布时间】:2021-01-29 09:04:22
【问题描述】:

我最近将 MapStruct 作为依赖项添加到我的项目中,但在将 MapStruct 作为依赖项添加到项目 .pom 文件并对其进行配置时遇到了问题。

这是我的 .pom 文件:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.opensourcedev</groupId>
    <artifactId>ticket-manager</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ticket-manager</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
        <org.mapstruct.version>1.4.1.Final</org.mapstruct.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>1.4.1.Final</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </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>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artefactId>mapstruct-processor</artefactId>
                            <version>1.4.1.Final</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                    <compilerArgs>
                        <compilerArg>-Amapstruct.defaultComponentModel=spring</compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

点击 clean 和 compile 后,我收到错误消息:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ticket-manager: Unable to parse configuration of mojo org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile for parameter artefactId: Cannot find 'artefactId' in class org.apache.maven.plugin.compiler.DependencyCoordinate

我不太明白这里有什么问题,但我可以猜到 没有处理或放错地方,我不知道。 我在以前的项目中使用过 MapStruct,但这是我第一次遇到这个问题

【问题讨论】:

    标签: java spring spring-boot maven mapstruct


    【解决方案1】:

    这与 MapStruct 无关。

    您的配置中有错字。

    你有artefactId,而不是artifactId。注意art 后面的e。

    【讨论】:

    • 我真是个傻瓜。我没有看到这个错字。但是我会好好利用它,因为我已经多次编辑了这个 .pom 文件,也许这不会导致问题。所以我会修正错字,点击“clean”,“compile”并报告
    猜你喜欢
    • 2014-01-11
    • 2016-02-12
    • 2019-03-22
    • 1970-01-01
    • 2015-02-25
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    • 2020-01-31
    相关资源
    最近更新 更多