在升级到弹簧引导2-m2(thymeleaf 3)后,对于与JPA关系对应的字段,我收到了失败的转换错误。Spring Boot 2.0.0M2 Thymeleaf 3无法转换字段
Failed to convert from type [@javax.persistence.ManyToOne @javax.persistence.JoinColumn com.pps2....entities.FormType] to type [java.lang.String] for value '[email protected]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.Optional<?>] to type [java.lang.String]
JPA实体
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "id_form_type")
private FormType type;
public FormType getType() {
return type;
}
的模板代码为:
<select th:field="*{type}" class="col-xs-12">
抛出类似失败的转换错误。
当然,当直接引用它的工作,但在这种情况下,它打破了项目中的很多模板。并生成name
作为type.id
而不是type
。
工作实例 <select th:field="*{type.id}" class="col-xs-12">
问题 - 为什么他们改变了API?有没有办法解决它而不重新检查所有模板(例如写入转换器?)?
为什么在除了Spring之外说“Thymeleaf未能转换”?如果是这样的话,JPA是如何处理转换问题的?又名调试,其中的问题是那些3位软件 –
谢谢我对Spring环境非常新鲜。 – BlackTea