1.1 lombok 詳細使用能夠看官網:https://projectlombok.org/features/alljava
1.2 使用@Data註解,這個註解的做用是:spring
@Data
All together now: A shortcut for @ToString
, @EqualsAndHashCode
, @Getter
on all fields, and @Setter
on all non-final fields, and @RequiredArgsConstructor
!springboot
1.3 修改咱們的domain.Company代碼以下:這裏已經沒必要謝getter/setter方法dom
package com.leilei.springbootcrm.domain; import lombok.Data; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import java.io.Serializable; import java.util.Date; @Entity @Data public class Company implements Serializable { private static final long serialVersionUID = 7471779949543151367L; @GeneratedValue @Id private Integer id; @Column(length = 50, nullable = false) private String CompanyName; private Date createTime; }
1.4 在上一篇 CompanyDaoTest追加一個測試用例,測試
@Test void testFindAll() { List<Company> companyList = companyDao.findAll(); System.out.println(companyList); }
1.5查看控制檯打印,發現咱們的toString()方法已經被重寫ui