No converter found capable of converting from type java.lang.String to type @org.springframework.data.repository.query.Param

前端 未结 2 1108
庸人自扰
庸人自扰 2021-01-07 13:06

I\'m building a MongoDb rest application with spring boot 1.1.5. I have created a repository:

@RepositoryRestResource(collectionResourceRel = \"SourceProduct         


        
相关标签:
2条回答
  • 2021-01-07 13:34

    After many try, i've found this solution

        @PostConstruct
    public void init(){
        GenericConversionService conversionService = (GenericConversionService) DefaultConversionService.getSharedInstance();
        conversionService.addConverter(new JPAConverter());
    }
    

    Converter and GenericConvert are supported.

    0 讨论(0)
  • 2021-01-07 13:45

    I fixed creating the bean in the following way:

    @Configuration
    public class MongoConvertersConfiguration {
    
        @Resource(name = "defaultConversionService")
        private GenericConversionService genericConversionService;
    
        @Bean
        public String2MongoUserConverter string2MongoUserConverter(){
            String2MongoUserConverter string2MongoUserConverter = new String2MongoUserConverter();
            genericConversionService.addConverter(string2MongoUserConverter);
            return string2MongoUserConverter;
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题