我想用Lombok的 ownBuilderMethod 创建一个类。单击 Shift + F10 (启动应用程序)后,出现错误:
Warning:(22, 8) java: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.sun.tools.javac.main.DelegatingJavaFileManager$DelegatingSJFM extends com.sun.tools.javac.main.DelegatingJavaFileManager implements javax.tools.StandardJavaFileManager
(..)
并且:
Error:(39, 19) java: cannot find symbol
symbol: class ProfileBuilder
location: class io.github.plkpiotr.fifabackend.model.Profile
没有此 builderMethodName 的纯@Builder可以正常工作,但带有“ ownBuilderMethod”的则不能正常工作。
源代码:
package io.github.plkpiotr.fifabackend.model;
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.util.UUID;
@Entity
@Table(name = "profiles")
@Data
@Builder(builderMethodName = "ownBuilderMethod")
//@AllArgsConstructor
//@NoArgsConstructor
public class Profile {
@Id
private String id;
@NotNull
@Pattern(regexp = "^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$")
private String nick;
@NotNull
private String password;
@NotNull
@Email
private String email;
public static ProfileBuilder builder() {
return ownBuilderMethod()
.id(UUID.randomUUID().toString());
}
}
答案 0 :(得分:2)
要解决这一事实,无法初始化LombokProcessor,您必须在Maven(pom.xml文件)中更改Lombok的依赖项:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
针对:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
</dependency>