Java 百里香不';I don’我不想和龙目巨人一起工作
我对SpringBoot项目中的Thymeleaf“forEach”和Lombok项目有问题。 如果我将生成getter和setter,那么一切都正常工作。如果我使用lombok注释,我会遇到以下异常: EL1008E:在“pl.codol.hibernate.model.CustomerEntity”类型的对象上找不到属性或字段“firstName”-可能不是公共的或无效的 有人知道什么是错误的吗?我读了其他的主题,但它们并没有帮助我解决问题 我的POJO课程:Java 百里香不';I don’我不想和龙目巨人一起工作,java,spring,tomcat,thymeleaf,lombok,Java,Spring,Tomcat,Thymeleaf,Lombok,我对SpringBoot项目中的Thymeleaf“forEach”和Lombok项目有问题。 如果我将生成getter和setter,那么一切都正常工作。如果我使用lombok注释,我会遇到以下异常: EL1008E:在“pl.codol.hibernate.model.CustomerEntity”类型的对象上找不到属性或字段“firstName”-可能不是公共的或无效的 有人知道什么是错误的吗?我读了其他的主题,但它们并没有帮助我解决问题 我的POJO课程: @Data // I also
@Data // I also used @Getter and @Setter, doesn't work
@NoArgsConstructor
@Entity
@Table(name = "CUSTOMER")
public class CustomerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CUSTOMER_ID")
private Long id;
@Column(name = "FIRST_NAME")
private String firstName;
@Column(name = "LAST_NAME")
private String lastName;
@Column(name = "EMAIL")
private String email;
@Override
public String toString() {
return "CustomerEntity{" +
"id=" + id +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", email='" + email + '\'' +
'}';
}
}
控制器:
@Controller
@RequestMapping("/customer")
public class CustomerController {
private CustomerService customerService;
@Autowired
public CustomerController(CustomerService customerService) {
this.customerService = customerService;
}
@RequestMapping("/list")
public String listCustomers(Model model) {
List<CustomerEntity> allCustomers = customerService.findAllCustomers();
model.addAttribute("customers", allCustomers);
return "list-customers";
}
}
@控制器
@请求映射(“/customer”)
公共类客户控制器{
私人客户服务;
@自动连线
公共CustomerController(CustomerService CustomerService){
this.customerService=customerService;
}
@请求映射(“/list”)
公共字符串列表客户(模型){
列出所有客户=customerService.findAllCustomers();
model.addAttribute(“客户”,所有客户);
返回“列出客户”;
}
}
导致问题的html文件的一部分:
<th:block th:each="customer : ${customers}">
<tr>
<td th:text="${customer.firstName}">...</td>
<td th:text="${customer.lastName}">...</td>
<td th:text="${customer.email}">...</td>
</tr>
</th:block>
...
...
...
我已经发现了一个问题
问题在于Intellij中缺少启用注释处理的复选框 请告诉我们哪个支票箱?如何启用它?我对百里香和龙目山也有同样的问题