intellij-idea - 在Lombok注释类上,IntelliJ IDEA Gradle生成失败

我有一个JHipster项目,在build.gradle中我增加了对Lombok的依赖性:


compile group: 'org.projectlombok', name: 'lombok', version: lombok_version



但是当我尝试从命令行构建时,我得到了构建错误,

命令行:

 
./gradlew build



 

错误:


/Users/.../source/v4.0/src/main/java/com/.../service/MyService.java:145: error: cannot find symbol


 log.info("Security Context:" + SecurityUtils.getCurrentUserLogin());


 ^


 symbol: variable log


 location: class MyService



错误:


/Users/.../source/v4.0/src/main/java/com/.../service/MyService.java:105: error: cannot find symbol


 myClass.setDescription(description);


 ^


 symbol: method setDescription(String)


 location: variable myClass of type MyClass



服务类:


import lombok.extern.slf4j.Slf4j; 


import org.springframework.stereotype.Service;



@Service


@Slf4j


public class MyService { 


 public void someMethod(){


 log.debug("Security Context:" + SecurityUtils.getCurrentUserLogin());


 MyClass myCLass = new MyClass();


 myClass.setDescription(description);


 }


}



实体类:


import lombok.Getter;


import lombok.NoArgsConstructor;


import lombok.Setter;


import javax.persistence.Entity;


import javax.persistence.Table;



@Entity


@Table(name="t_juror_file_update")


@Getter


@Setter


@NoArgsConstructor


public class MyClass {



 private String description;



}



任何帮助将不胜感激。

时间: 作者:

你将需要将lombok指定为annotation处理器,为此,你需要在Jhipster项目中向build.gradle添加以下内容。


apply plugin: 'net.ltgt.apt'



dependencies { 


 provided"org.projectlombok:lombok:$lombokVersion"


 apt"org.projectlombok:lombok:$lombokVersion"



 /** ... */


}



Jhipster使用net.ltgt.gradle:gradle-apt-plugin进行annotation处理。

对于IntelliJ设置,应该检查Enable annotation Processing

更多信息:Project Lombok - Android说明

作者:
...