春季启动版本升级后如何解决Converter的异常

时间:2019-05-14 18:13:03

标签: spring-boot spring-data

我最近从Spring Boot版本1.5.7升级到了2.1.4。升级后,我遇到了Converters异常,其中@Query注释与spring数据一起使用。 下面的异常堆栈跟踪。

您能否建议是否应该更改任何依赖版本来解决此问题?还是需要编写客户转换器?

Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.HashMap<?, ?>] to type [@org.springframework.data.jpa.repository.Query com.example.Stage.XXXX]
    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194)
    at org.springframework.core.convert.support.CollectionToCollectionConverter.convert(CollectionToCollectionConverter.java:89)
    at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
    ... 150 more

发布的代码:

@RepositoryRestResource
public interface FileStagedEventRepository extends JpaRepository<FileStagedEvent, Long> {

@Query(value = "select new map(id as id, fileName as fileName, recType as recType) FROM FileStagedEvent where id = :id", nativeQuery = true)
    public Map<String, String> findById(@Param("id") Long id);  
}

select new map部分似乎是问题所在。我不确定此地图功能如何工作。

0 个答案:

没有答案