eclipse java注解处理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9850952/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 08:37:25  来源:igfitidea点击:

eclipse java annotation processing

javaeclipseeclipse-indigoaptannotation-processing

提问by Erwin Smout

I want to do something using Annotation processing in eclipse jdt.

我想在 eclipse jdt 中使用 Annotation 处理做一些事情。

Eclipse jdtapt help tells me I should configure things on the java/compiler/annotation processing preferences page.

Eclipse jdtapt 帮助告诉我应该在 java/compiler/annotation 处理首选项页面上配置内容。

But on my installation (Indigo), the compiler section doesn't have this annotation processing subsection. It only has building,errors/warnings,javadoc, task tags.

但是在我的安装(Indigo)上,编译器部分没有这个注释处理子部分。它只有建筑、错误/警告、javadoc、任务标签。

Is something wrong with my installation ?

我的安装有问题吗?

采纳答案by thkala

The annotation processing tab does not exist in the Preferences page that is accessible from the Eclipse menu bar. It is a project-specific menu that is accessible if you right-click on a project in the Project Explorer and select Preferences in the pop-up menu that will appear.

可从 Eclipse 菜单栏访问的 Preferences 页面中不存在注释处理选项卡。这是一个特定于项目的菜单,如果您在项目资源管理器中右键单击项目并在出现的弹出菜单中选择首选项,则可以访问该菜单。

You may have to enable project-specific settings for the Java compiler tab and annotation processing explicitly before it will appear, as mentioned in this tutorial.

本教程中所述,您可能必须在 Java 编译器选项卡和注释处理出现之前显式启用项目特定的设置。

回答by Dave Dopson

I autogenerate my eclipse project files, so I prefer setting this stuff w/o using the UI ...

我自动生成我的 eclipse 项目文件,所以我更喜欢使用 UI 设置这些东西...

project/.factorypath:

项目/.工厂路径:

<factorypath>
    <factorypathentry kind="WKSPJAR" id="../build/EpicBuilder.jar" enabled="true" runInBatchMode="false"/>
</factorypath>

project/.settings/org.eclipse.jdt.apt.core.prefs:

项目/.settings/org.eclipse.jdt.apt.core.prefs:

eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
org.eclipse.jdt.apt.reconcileEnabled=true

project/.settings/org.eclipse.jdt.core.prefs:

项目/.settings/org.eclipse.jdt.core.prefs:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.processAnnotations=enabled

回答by Janning

Maybe you are running a multi-moduleproject. You are looking for the annotation processing tab in the parent project which might have a <packaging>pom</packaging>in its pom.xml

也许您正在运行一个多模块项目。您正在寻找父项目注释处理选项卡可能有一个<packaging>pom</packaging>在其pom.xml

If so, you won't find the tab here. Go to a specific project with packaging jarand you will see the tab.

如果是这样,您将不会在此处找到该选项卡。转到带有包装的特定项目,jar您将看到该选项卡。

I search for this a few hours, so maybe this helps someone saving time.

我搜索了几个小时,所以也许这有助于节省时间。