无法解析 MapStruct 插件的配置。

huangapple go评论118阅读模式
英文:

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>

在执行cleancompile之后,我收到以下错误消息:

无法执行目标 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:

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

	&lt;properties&gt;
		&lt;java.version&gt;11&lt;/java.version&gt;
		&lt;org.mapstruct.version&gt;1.4.1.Final&lt;/org.mapstruct.version&gt;
	&lt;/properties&gt;

	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-validation&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
		&lt;/dependency&gt;

		&lt;dependency&gt;
			&lt;groupId&gt;mysql&lt;/groupId&gt;
			&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
			&lt;scope&gt;runtime&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
			&lt;artifactId&gt;lombok&lt;/artifactId&gt;
			&lt;optional&gt;true&lt;/optional&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
			&lt;artifactId&gt;mapstruct&lt;/artifactId&gt;
			&lt;version&gt;1.4.1.Final&lt;/version&gt;
		&lt;/dependency&gt;

		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
			&lt;scope&gt;test&lt;/scope&gt;
			&lt;exclusions&gt;
				&lt;exclusion&gt;
					&lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
					&lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
				&lt;/exclusion&gt;
			&lt;/exclusions&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;

	&lt;build&gt;
		&lt;plugins&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
				&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
			&lt;/plugin&gt;
			&lt;plugin&gt;
				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
				&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
				&lt;version&gt;3.8.1&lt;/version&gt;
				&lt;configuration&gt;
					&lt;source&gt;${java.version}&lt;/source&gt;
					&lt;target&gt;${java.version}&lt;/target&gt;
					&lt;annotationProcessorPaths&gt;
						&lt;path&gt;
							&lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
							&lt;artefactId&gt;mapstruct-processor&lt;/artefactId&gt;
							&lt;version&gt;1.4.1.Final&lt;/version&gt;
						&lt;/path&gt;
						&lt;path&gt;
							&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
							&lt;artifactId&gt;lombok&lt;/artifactId&gt;
							&lt;version&gt;${lombok.version}&lt;/version&gt;
						&lt;/path&gt;
					&lt;/annotationProcessorPaths&gt;
					&lt;compilerArgs&gt;
						&lt;compilerArg&gt;-Amapstruct.defaultComponentModel=spring&lt;/compilerArg&gt;
					&lt;/compilerArgs&gt;
				&lt;/configuration&gt;
			&lt;/plugin&gt;
		&lt;/plugins&gt;
	&lt;/build&gt;

&lt;/project&gt;

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 &#39;artefactId&#39; 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.

huangapple
  • 本文由 发表于 2020年10月15日 06:00:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/64362089.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定