我在 Mapstruct 中收到以下错误。根据各种帖子,此错误不应出现在最新版本中。
以下是所有配置:
错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project Snow: Compilation failure
[ERROR] /C:/Projects/Now/src/main/java/com/integrator/util/LicenseMapper.java:[20,25] Unknown property "updateDate" in result type com.integrator.license.License. Did you mean "updatedDate"?
[ERROR] -> [Help 1]
代码:
@Mappings({
@Mapping(source = "updatedDate", target = "updateDate", dateFormat = "yyyy-MM-dd'T'HH:mm:ss"),
@Mapping(source = "purchaseDate", target = "purchaseDate", dateFormat = "yyyy-MM-dd'T'HH:mm:ss")
})
License entityToDao(com.integrator.vo.license.License source);
POM:
<properties>
<org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
</properties>
.
.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</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>1.18.10</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
这个问题是在代码中吗?
最佳答案
您的目标是target = "updateDate"
应该是target = "updatedDate"
你错过了“updated”中的 d
关于java - Mapstruct:结果类型 com.integrator.license.License 中存在未知属性 "updateDate"。您的意思是 "updatedDate"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59624746/