{"record":{"id":"82b16b14219ebbec","repo":"chinabugotech/hutool","slug":"can-not-converter-from-to","errorCode":null,"errorMessage":"Can not Converter from [{}] to [{}]","messagePattern":"Can not Converter from \\[(.+?)\\] to \\[(.+?)\\]","errorType":"exception","errorClass":"ConvertException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/convert/ConverterRegistry.java","lineNumber":248,"sourceCode":"\t\t\t} else {\n\t\t\t\t// 无法识别的泛型类型，按照Object处理\n\t\t\t\treturn (T) value;\n\t\t\t}\n\t\t}\n\n\t\t// 特殊类型转换，包括Collection、Map、强转、Array等\n\t\tfinal T result = convertSpecial(type, rowType, value, defaultValue);\n\t\tif (null != result) {\n\t\t\treturn result;\n\t\t}\n\n\t\t// 尝试转Bean\n\t\tif (BeanUtil.isBean(rowType)) {\n\t\t\treturn new BeanConverter<T>(type).convert(value, defaultValue);\n\t\t}\n\n\t\t// 无法转换\n\t\tthrow new ConvertException(\"Can not Converter from [{}] to [{}]\", value.getClass().getName(), type.getTypeName());\n\t}\n\n\t/**\n\t * 转换值为指定类型<br>\n\t * 自定义转换器优先\n\t *\n\t * @param <T>          转换的目标类型（转换器转换到的类型）\n\t * @param type         类型\n\t * @param value        值\n\t * @param defaultValue 默认值\n\t * @return 转换后的值\n\t * @throws ConvertException 转换器不存在\n\t */\n\tpublic <T> T convert(Type type, Object value, T defaultValue) throws ConvertException {\n\t\treturn convert(type, value, defaultValue, true);\n\t}\n\n\t/**","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/convert/ConverterRegistry.java#L230-L266","documentation":"ConverterRegistry.convert is the central dispatcher. After checking custom/standard converters, special-type conversion (Collection/Map/Array/Cast), and bean conversion, if nothing handled the value it throws ConvertException with source and target type names.","triggerScenarios":"Calling Convert.convert(value, TargetType.class) where TargetType is not a registered convertible type, not a bean, and no special-case handler applies (e.g. interfaces, abstract classes, generic type variables, arrays of unsupported components).","commonSituations":"Targeting abstract/interface types; using TypeReference with unresolved generics; converting to a class with no public no-arg constructor that BeanUtil cannot treat as a bean.","solutions":["Register a custom Converter for the target type via ConverterRegistry.getInstance().putCustom(type, converter).","Convert to an intermediate concrete type (Map or existing bean) then map manually.","If the target is meant to be a bean, ensure it has a public no-arg constructor and readable properties so isBean() returns true.","Catch ConvertException and provide a fallback or default."],"exampleFix":"// before - no converter for MyType\nMyType r = Convert.convert(obj, MyType.class);\n\n// after - register a converter\nConverterRegistry.getInstance().putCustom(MyType.class, new MyTypeConverter());\nMyType r = Convert.convert(obj, MyType.class);","handlingStrategy":"fallback","validationCode":"Class<?> rawType = TypeUtil.getClass(type);\nif (rawType == null || (ConverterRegistry.getInstance().getConverter(type, true) == null\n        && !BeanUtil.isBean(rawType))) {\n    // register a custom converter or convert via intermediate Map first\n    ConverterRegistry.getInstance().putCustom(rawType, new MyConverter());\n}\nreturn Convert.convert(value, type);","typeGuard":null,"tryCatchPattern":"try {\n    return Convert.convert(value, type);\n} catch (ConvertException e) {\n    if (e.getMessage().startsWith(\"Can not Converter from\")) {\n        return defaultValue; // or register converter and retry\n    }\n    throw e;\n}","preventionTips":["Register custom converters up-front for domain types.","Ensure target types are concrete beans with a public no-arg constructor.","Catch ConvertException at the boundary and degrade gracefully."],"tags":["convert","no-converter","registry"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}