MapStruct生成代码

时间:2016-08-05 03:08:27

标签: mapstruct

我正在学习根据参考指南使用MapStruct。 日食是

面向Web开发人员的Eclipse Java EE IDE。 版本:开普勒服务第2版

enter image description here

pom.xml 如下所示与参考指南相同

HO
HO
HO
HO
MO
MFG, MO
MO
MO
HO

<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>
    <groupId>com.map</groupId>
    <artifactId>MapStruct</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <org.mapstruct.version>1.0.0.Final</org.mapstruct.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-jdk8</artifactId>
            <version>${org.mapstruct.version}</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.bsc.maven</groupId>
                    <artifactId>maven-processor-plugin</artifactId>
                    <version>2.2.4</version>
                    <configuration>
                        <defaultOutputDirectory>
                            ${project.build.directory}/generated-sources
                        </defaultOutputDirectory>
                        <processors>
                            <processor>org.mapstruct.ap.MappingProcessor</processor>
                        </processors>
                        <options>
                            <mapstruct.suppressGeneratorTimestamp>
                                true</mapstruct.suppressGeneratorTimestamp>
                            <mapstruct.defaultComponentModel>cdi</mapstruct.defaultComponentModel>
                        </options>
                    </configuration>
                    <executions>
                        <execution>
                            <id>process</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>process</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

它表示在构建项目时会生成实现代码。但是,它似乎不会在 target / generated-sources 文件夹

下生成

1 个答案:

答案 0 :(得分:1)

添加M2E插件后,使用mvn -clean install,生成代码