私はロンボクでプロジェクトを構築しようとしています。これは私がdependencieとして持っているものです。ロンボクをグラデルとスプリングブートで使用する
dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.social:spring-social-facebook")
compile("org.springframework.social:spring-social-twitter")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("junit:junit")
compile("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("mysql:mysql-connector-java")
compileOnly("org.projectlombok:lombok:1.16.10")
}
私はアノテーションを含めることができ、私はエディタにロンボクを含めました。私はロンボクを使用してコードをコンパイルし、ロンボクが生成するメソッドにcalを作成することさえできます。
これは私の実体である:
@Data
@Entity
@Table(name = "TEA_USER", uniqueConstraints = {
@UniqueConstraint(columnNames = { "USR_EMAIL" }),
@UniqueConstraint(columnNames = { "USR_NAME" })
})
public class User {
@NotNull
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="USR_ID")
private long id;
@NotNull
@Column(name="USR_FNAME")
private String firstName;
@NotNull
@Column(name="USR_LNAME")
private String lastName;
@NotNull
@Min(5)
@Max(30)
@Column(name="USR_NAME")
private String username;
@Column(name="USR_EMAIL")
private String email;
@Min(8)
@NotNull
@Column(name="USR_PASSWORD")
private String password;
}
そして、これは罰金コンパイル機能である:
@PostMapping("/registration/register")
public String doRegister (@ModelAttribute @Valid User user, BindingResult result){
user.getEmail();
System.out.println(user.getFirstName());
if (result.hasErrors()) {
return "register/customRegister";
}
this.userRepository.save(user);
return "register/customRegistered";
}
しかし、私はbootRunを実行し、私はこれは私が得る例外であるfuncionalityにアクセスしようとすると、 :
org.springframework.beans.NotReadablePropertyException: Invalid property 'firstName' of bean class [com.lucasfrossard.entities.User]: Bean property 'firstName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
しかし、私が手動でセッターとゲッターを含めると、これはうまくいきます。私は何が起こっているのか、どのように修正するのか分からない。何か案が?
私たちもこの設定をしており、追加のプラグインを用意する必要はありません。どのIDEを使用していますか? IDE用のプラグインをインストールする必要がありますね。 https://projectlombok.org/download.html – questionare
このプラグインは私に多くの助けになりました、ありがとうございます! なぜ起こるのか教えていただけますか? Mavenプロジェクトでは、をlombokに追加すれば十分ですが、ここではgradleでは、代わりに奇妙なプラグインが必要です。 –