easypoi报错之no getter for property
1.具体报错内容
cn.afterturn.easypoi.exception.excel.ExcelExportException: Excel导出错误
There is no getter for property named 'N1' in 'class com.baizhi.entity.Employee
2.报错原因
easypoi获取属性没有getter方法
说明----->属性的get方法有问题----->属性命名有问题
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ExcelTarget("employee")
public class Employee {
@Excel(name="编号")
private String id;
@Excel(name="姓名")
private String N1;
@Excel(name="年龄")
private Integer age;
@Excel(name="生日",format = "yyyy-MM-dd HH:mm:ss")
private Date bir;
@Excel(name="状态",replace = {"激活_1","锁定_0"})
private String status;
}
说明:
private String N1中的属性名没有遵循小驼峰命名规则
3.正确的写法
private String n1;
4.总结
代码一定要规范
1.属性的命名遵循小驼峰
2.方法的命名遵循小驼峰
3.类,接口等命名遵循大驼峰规则
4.数据库和java实体类属性的映射关系
…
另一篇参考文章
https://blog.csdn.net/shaoming314/article/details/108558009
个人csdn博客网址:https://blog.csdn.net/shaoming314