Lombok plugin is installed. Using IntelliJ 15. Structure of model shows the getters and setters but I get the following error from Thymeleaf.
Error:
Invalid property 'postTitle' of bean class [com.blog.domain.Post]: Bean property 'postTitle' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
The model:
@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;
}
The controller method that loads the form:
@GetMapping("/create")
public String postForm(Post post, Model model) {
model.addAttribute("authors", authorService.getAllAuthors());
return "postform";
}
The field where error occurs:
<input id="postTitle" type="text" th:field="*{postTitle}" />
Any ideas where I'm going wrong? Adding the getters and setters manually solves the problem. What is lombok doing here that is breaking it?
I ran into this using a boolean named "isEnabled". Renaming it to "enabled" worked. Not sure about the reason for this though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.