英文:
Unable to parse configuration of MapStruct plugin
问题
以下是翻译好的部分:
我最近在我的项目中添加了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>
<!-- 依赖列表 -->
</dependencies>
<build>
<plugins>
<!-- 插件列表 -->
</plugins>
</build>
</project>
在执行clean和compile之后,我收到以下错误消息:
无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile),项目 ticket-manager: 无法解析参数 artefactId 的 mojo org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile 的配置:在类 org.apache.maven.plugin.compiler.DependencyCoordinate 中找不到 'artefactId'
我不太理解问题出在哪里,但我猜想 <artefactId> 没有被处理或者放错位置了,我不太清楚。我之前在其他项目中使用过MapStruct,但这是我第一次遇到这个问题。
英文:
I was recently adding a MapStruct as a dependency to my project but I have run into issue with adding MapStruct as a dependency into project .pom file and congiguring it.
Here is my .pom file:
<?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>
After I hit clean and compile I get error message:
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
I don't quite understand what is the problem here but I can guess that the <artefactId> is not processed or is misplaced, i don't know.
I have used MapStruct in my previous projects but this is the first time I have encountered this problem
答案1
得分: 1
这与MapStruct无关。
您的配置中有一个拼写错误。
应该是 artifactId
,而不是 artefactId
。请注意在 art
后面有一个额外的 e
。
英文:
This has nothing to do with MapStruct.
You have a typo in your configuration.
Instead of artifactId
you have artefactId
. Notice the e
after the art
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论