【发布时间】:2018-12-11 19:25:36
【问题描述】:
我有一个使用Spring 4.3.12.RELEASE 的Java Web 应用程序,我想集成mapstruct 以自动生成DTOs。
首先,我用一些假类创建了一个新的独立项目,它工作正常,所以我可以找到我新生成的类 *impl.java。
之后,我在我的项目中使用相同的类和相同的 pom 文件创建了一个新的 maven 模块,但是我的插件不起作用并且没有生成 impls!
这是我所拥有的一个例子:
public class SimpleSource {
private int id;
private String name;
//constructors and getters and setters
}
public class SimpleDestination {
private int id;
private String name;
//constructors and getters and setters
}
@Mapper(componentModel = "spring")
public interface SimpleSourceDestinationMapper {
SimpleDestination sourceToDestination(SimpleSource source);
SimpleSource destinationToSource(SimpleDestination destination);
}
pom.xml:
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.project</groupId>
<artifactId>project-parent</artifactId>
<version>${version.proj}</version>
</parent>
<groupId>fr.project</groupId>
<artifactId>service-dtos</artifactId>
<name>service-dto</name>
<dependencies>
<dependency>
<groupId>fr.pasteur</groupId>
<artifactId>service</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>
<build>
<finalName>service-dto</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
我做错了吗?
【问题讨论】:
-
这个
<version>${version.proj}</version>不起作用... -
@khmarbaise Thnx 对于您的评论,我删除了所有出现的 ${version.proj} 但生成 mapstruct 不起作用
-
我在当前项目中使用 CDI 和 Spring,请问有什么问题吗??
标签: java spring maven mapstruct