spring-boot Spring boot + Hibernate + Web UI (Thymeleaf) Entities and Repositories


A simple entity: Using Lombok @Getter and @Setter annotations to generate getters and setters for us

@Getter @Setter
public class Message {
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    private String id;
    private String message;


I am using UUID based ids and lombok to generate getters and setters.

A simple repository for the entity above:

public interface MessageRepository extends CrudRepository<Message, String> {

More on respositories: spring data docs

Make sure entities reside in a package that is mapped in em.setPackagesToScan (defined in LocalContainerEntityManagerFactoryBean bean) and repositories in a package mapped in basePackages (defined in @EnableJpaRepositories annotation)