Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation error for annotations in Java 1.8 and IntelliJ IDEA 14

I was playing with Java annotation processing. Application build fails in IntelliJ IDEA, while a maven build ends successfully. 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. 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?

like image 610
naXa Avatar asked Oct 08 '15 13:10

naXa


People also ask

How do I fix a compilation error in IntelliJ?

Create a new project (trying to see if my current project files somehow all got messed up, but the problems persist even with new projects) Uninstall + Reinstall. Uninstall, delete as many local files as I can find (in Program Files, Program Files (x86), dot folders in my user folder, folders in AppData) + Reinstall.

How do I enable annotation processing in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Compiler | Annotation Processors.

How do I check my annotations in IntelliJ?

Enable annotationsRight-click the gutter in the editor or in the Differences Viewer and select Annotate with Git Blame from the context menu. You can assign a custom shortcut to the Annotate command: go to the Keymap page of the IDE settings Ctrl+Alt+S and look for Version Control Systems | Git | Annotate.


1 Answers

You need to configure a separate annotation profile for your module.

  1. Create an annotation profile
    1. In the Annotation Processors page, click add.
    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. (By default, all the modules of a project are associated with the default profile.)
    2. Click Move to, or press F6.
    3. From the drop-down list, select the target profile to move the selected module to. Annotation profile - move
  3. Configure annotation processing for a profile
    1. Enable annotation processing for the default profile.
    2. Disable annotation processing for the profile, you've just created.

This answer is based on an article from IntelliJ IDEA Help.

like image 197
naXa Avatar answered Oct 21 '22 12:10

naXa