如何在保存时在eclipse中运行注释处理器

And*_*Dev 8 eclipse code-generation save maven annotation-processing

目前我在eclipse中为一个项目生成带有注释处理器的文件

Right click on project > Run As > Maven Clean
Right click on project > Run As > Maven install
Run Code Online (Sandbox Code Playgroud)

这非常耗时.如何设置eclipse以使其在保存时运行注释处理器?

我有"自动构建"功能集,但它似乎忽略了注释处理器.BTW我正在使用m2e apt插件"自动配置JDT APT激活".

M-R*_*avi 1

我认为你需要一个触发器来运行 Maven 目标,所以:

您必须添加有效的 Maven 生命周期操作

通过maven install plugin自动在本地部署的 jar 示例

<build>
    <!-- ... -->

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>

                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-jar-plugin</artifactId>
                                    <versionRange>[2.0,)</versionRange>
                                    <goals>
                                        <goal>jar</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute>
                                        <runOnConfiguration>true</runOnConfiguration>
                                        <runOnIncremental>true</runOnIncremental>
                                    </execute>
                                </action>
                            </pluginExecution>

                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-install-plugin</artifactId>
                                    <versionRange>[2.5.0,)</versionRange>
                                    <goals>
                                        <goal>install</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute>
                                        <runOnConfiguration>true</runOnConfiguration>
                                        <runOnIncremental>true</runOnIncremental>
                                    </execute>
                                </action>
                            </pluginExecution>

                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
Run Code Online (Sandbox Code Playgroud)

提示:与每次更改源文件 (GWT) 时都会调用 Maven 项目生成器相关,并作为警告:如果您已将测试包含在正常的 Maven 构建周期中,安装通常会包含测试