[英]Thymeleaf not recognizing Lombok getters and setters
已安裝Lombok插件。 使用IntelliJ 15.模型的結構顯示了getter和setter但是我從Thymeleaf得到以下錯誤。
錯誤:
bean類[com.blog.domain.Post]的屬性'postTitle'無效:Bean屬性'postTitle'不可讀或getter方法無效:getter的返回類型是否與setter的參數類型匹配?
該模型:
@Entity
public @Data class Post {
@Id
@GeneratedValue
private Long id;
@NotEmpty
private String postTitle;
@NotNull
@ManyToOne
private Author postAuthor;
@NotNull
@Temporal(TemporalType.DATE)
private Date postDate;
@Column(columnDefinition = "TEXT")
private String postTeaser;
@Column(columnDefinition = "TEXT")
private String postBody;
}
加載表單的控制器方法:
@GetMapping("/create")
public String postForm(Post post, Model model) {
model.addAttribute("authors", authorService.getAllAuthors());
return "postform";
}
發生錯誤的字段:
<input id="postTitle" type="text" th:field="*{postTitle}" />
我出錯的任何想法? 手動添加getter和setter可以解決問題。 Lombok在這做什么打破了它?
我使用名為“isEnabled”的布爾值遇到了這個問題。 將其重命名為“啟用”工作。 雖然不確定原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.