Lombok IntelliJ IDEA Plugin: Use of var is disable

2019-07-29 11:07发布

问题:

I'm using the Lombok Plugin for IntelliJ IDEA. When try to run Java code using the var keyword, I get the following error:

Use of var is disabled by default. Please add 'lombok.var.flagUsage = ALLOW' to 'lombok.config' if you want to enable is.

How do you do that in IntelliJ IDEA? I created the lombok.config in the project root and pasted lombok.var.flagUsage = ALLOW but it didn't fix it. val is working but not var. I can't seem to find clear instructions on enabling var.

My Lombok maven dependency is:

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.18</version>
    <scope>provided</scope>
</dependency>

回答1:

You may need to recompile everything in order to observe the effect.

Actually, any change of any lombok.config anywhere should trigger a recompilation of all classes in the subtree. This is not the case as such changes are rare and don't warrant the probably non-trivial amount of work.