简体   繁体   English

Java 1.8和IntelliJ IDEA 14中注释的编译错误

[英]Compilation error for annotations in Java 1.8 and IntelliJ IDEA 14

I was playing with Java annotation processing. 我正在玩Java注释处理。 Application build fails in IntelliJ IDEA, while a maven build ends successfully. IntelliJ IDEA中的应用程序构建失败,而maven构建成功结束。 I am sure that provider class exists, yet I get the following error: 我确信提供程序类存在,但我收到以下错误:

java: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider <my class> not found.

I suppose that's because of a module X , that should be compiled with -proc:none argument. 我想这是因为模块X应该用-proc:none参数编译。 But I need annotation processing to be enabled for the rest of application. 但我需要为其余的应用程序启用注释处理。 How to configure IntelliJ IDEA build proccess to skip a specific module during annotation proccessing? 如何配置IntelliJ IDEA构建过程以在注释过程中跳过特定模块?

You need to configure a separate annotation profile for your module. 您需要为模块配置单独的注释配置文件。

  1. Create an annotation profile 创建注释配置文件
    1. In the Annotation Processors page, click 在“ 注释处理器”页面中,单击“确定” 加 .
    2. In the 'Create new profile' dialog box, specify the profile name. 在“创建新配置文件”对话框中,指定配置文件名称。
  2. Associate a module with an annotation profile 将模块与注释配置文件相关联
    1. Select your module in the list of modules under a default profile. default配置文件下的模块列表中选择您的模块。 (By default, all the modules of a project are associated with the default profile.) (默认情况下,项目的所有模块都与default配置文件相关联。)
    2. Click 点击 搬去 , or press F6 . ,或按F6
    3. From the drop-down list, select the target profile to move the selected module to. 从下拉列表中,选择要将所选模块移动到的目标配置文件。 注释配置文件 - 移动
  3. Configure annotation processing for a profile 配置配置文件的注释处理
    1. Enable annotation processing for the default profile. 启用 default配置文件的注释处理。
    2. Disable annotation processing for the profile, you've just created. 您刚刚创建的配置文件禁用注释处理。

This answer is based on an article from IntelliJ IDEA Help . 这个答案基于IntelliJ IDEA帮助中的一篇文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IntelliJ IDEA - Java 注释 - IntelliJ IDEA - Java annotations Java 错误:IntelliJ IDEA 不支持发行版 14 - Java error: release version 14 not supported in IntelliJ IDEA Lombok 的 IntelliJ IDEA 编译错误 - IntelliJ IDEA compilation error with Lombok 无法在 Intellij IDEA 中运行 Java 代码:编译时出错 - Unable to run the Java code in Intellij IDEA : error during Compilation 使用带有java 1.8和netbeans的maven-compiler-plugin 2.5.1在Java中进行注释的编译错误 - Compilation error for annotations in Java using maven-compiler-plugin 2.5.1 with java 1.8 and netbeans 上次修改的Java 1.8编译错误 - Java 1.8 compilation error for lastmodified 如何在 IntelliJ IDEA 14 中为当前项目工作配置注释处理? - How to configure annotations processing in IntelliJ IDEA 14 for current project work? IntelliJ IDEA 告诉我“Error:java: Compilation failed: internal java compiler error idea” - IntelliJ IDEA tells me "Error:java: Compilation failed: internal java compiler error idea" IntelliJ IDEA 2017.1.3给出错误-即使将Project SDK设置为Java 1.8 JDK也未定义Project SDK - IntelliJ IDEA 2017.1.3 giving error - Project SDK is not defined, even on setting Project SDK to Java 1.8 JDK Intellij Idea中的Scala / Java编译顺序 - Scala/Java compilation order in Intellij Idea
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM