{"record":{"id":"28b649c9e689eb73","repo":"baomidou/mybatis-plus","slug":"s","errorCode":null,"errorMessage":"%s 的名称转换结果为空，请检查是否配置问题","messagePattern":"(.+?) 的名称转换结果为空，请检查是否配置问题","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/INameConvert.java","lineNumber":85,"sourceCode":"        }\n\n        @Override\n        public @NotNull String propertyNameConvert(@NotNull TableField field) {\n            return processName(field.getName(), strategyConfig.entity().getColumnNaming(), strategyConfig.getFieldPrefix(), strategyConfig.getFieldSuffix());\n        }\n\n        private String processName(String name, NamingStrategy strategy, Set<String> prefix, Set<String> suffix) {\n            String propertyName = name;\n            // 删除前缀\n            if (!prefix.isEmpty()) {\n                propertyName = NamingStrategy.removePrefix(propertyName, prefix);\n            }\n            // 删除后缀\n            if (!suffix.isEmpty()) {\n                propertyName = NamingStrategy.removeSuffix(propertyName, suffix);\n            }\n            if (StringUtils.isBlank(propertyName)) {\n                throw new RuntimeException(String.format(\"%s 的名称转换结果为空，请检查是否配置问题\", name));\n            }\n            // 下划线转驼峰\n            if (NamingStrategy.underline_to_camel.equals(strategy)) {\n                return NamingStrategy.underlineToCamel(propertyName);\n            }\n            return propertyName;\n        }\n    }\n}\n","sourceCodeStart":67,"sourceCodeEnd":95,"githubUrl":"https://github.com/baomidou/mybatis-plus/blob/bf67d907478c724120bf76292da54abf9e73c2b3/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/INameConvert.java#L67-L95","documentation":"Thrown by INameConvert.processName when, after removing the configured table prefix and/or suffix, the remaining name is blank. The generator refuses to build a class/property name from an empty string, because prefix/suffix stripping consumed the entire table name. The original table name is included in the message so you can see which table triggered it.","triggerScenarios":"Calling the code generator with strategyConfig.tablePrefix or tableSuffix set to a value equal to the whole table name (e.g. table 'sys' with prefix 'sys'), or a prefix/suffix that matches after case differences, so NamingStrategy.removePrefix/removeSuffix leaves an empty string before the underline-to-camel step.","commonSituations":"Setting tablePrefix too greedily (e.g. prefix 't' against a table named 't'), copying a prefix configuration from another project whose tables share a prefix, or combining a short table name with a long configured suffix. Also happens when entity name conversion (entityNameConvert) is fed a table whose name equals the removed affix.","solutions":["Inspect the table name shown in the message and compare it against your StrategyConfig tablePrefix/tableSuffix values; the affix removal consumed the whole name.","Narrow the prefix/suffix (e.g. use 'sys_' instead of 'sys') or rename the offending table so a non-empty stem remains.","Exclude the offending table via strategyConfig.include()/addInclude so it is not generated, if its name cannot change.","Implement a custom INameConvert that returns a safe default when stripping produces an empty string."],"exampleFix":"// before\nStrategyConfig strategy = new StrategyConfig();\nstrategy.setTablePrefix(\"sys\"); // table named 'sys' -> strips to \"\"\n\n// after\nStrategyConfig strategy = new StrategyConfig();\nstrategy.setTablePrefix(\"sys_\"); // table 'sys_user' -> 'user'","handlingStrategy":"validation","validationCode":"// Before generating: ensure no table name is fully consumed by affixes\nSet<String> prefix = strategyConfig.getTablePrefix();\nSet<String> suffix = strategyConfig.getTableSuffix();\nfor (String table : allTableNames /* from DatabaseMetaData getTables */) {\n    String rest = table;\n    for (String p : prefix) if (rest.startsWith(p)) { rest = rest.substring(p.length()); break; }\n    for (String s : suffix) if (rest.endsWith(s) && rest.length() > s.length()) { rest = rest.substring(0, rest.length() - s.length()); break; }\n    if (rest.isBlank()) throw new IllegalStateException(\"Affix config empties table name: \" + table);\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.generate();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"名称转换结果为空\")) {\n        // log offending table from message, fix prefix/suffix config\n    }\n    throw e;\n}","preventionTips":["Prefer prefix values that include the separator (sys_ not sys) so they can never equal a whole table name.","Keep the table list (include) explicit when using aggressive affix stripping.","Unit-test the generator config against the real table list in CI so bad affixes fail at build time."],"tags":["mybatis-plus","code-generator","naming-strategy","configuration"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}