Dopiero rozpoczynam zabawę z thymeleaf i mam błąd, którego nie znam przyczyny:
Entity:
package pl.coderslab.entity;
import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Set;
@Entity
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode
@ToString
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(unique = true)
private String login;
@Column(unique = true)
@Email
@NotEmpty
private String email;
@NotEmpty
private String username;
@NotEmpty
private String surname;
@NotEmpty
private String password;
private boolean enabled;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
private Project project;
@ManyToMany(fetch = FetchType.LAZY,
cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
},
mappedBy = "users")
private List<Task> tasks;
@ManyToMany
@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
private Set<Role> roles;
private String passwordConfirm;
public User (User user){
this.password = user.getPassword();
this.id = user.getId();
this.surname = user.getSurname();
this.username = user.getUsername();
this.login = user.getLogin();
this.email = user.getEmail();
this.enabled = user.isEnabled();
}
}
Formularz:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>CRM</h1>
<p>Welcome in CRM Application</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-login">
<form id="register-form" method="post" th:action="@{'/registration'}" th:object="${user}" role="form" style="display:block">
<div class="form-group">
<input type="text" th:field="*{login}" name="login" id="login" tabindex="1" class="form-control" placeholder="Login">
</div>
<div class="form-group">
<input th:field="*{username}" name="username" id="username" tabindex="1" class="form-control" placeholder="Username">
</div>
<div class="form-group">
<input th:field="*{surname}" name="surname" id="surname" tabindex="1" class="form-control" placeholder="Last name">
</div>
<div class="form-group">
<input th:field="*{email}" name="email" id="email" tabindex="1" class="form-control" placeholder="Email">
</div>
<div class="form-group">
<input th:field="*{password}" type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password">
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="register-submit" id="register-submit" tabindex="4" class="form-control btn btn-register" value="Register Now">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Wyświetlany błąd:
org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor' (template: "registration" - line 25, col 44)