{"record":{"id":"7da5c3fa320e7145","repo":"baomidou/mybatis-plus","slug":"xml","errorCode":null,"errorMessage":"注册用户资源目录的xml文件失败","messagePattern":"注册用户资源目录的xml文件失败","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/MyBaitsRuntimeHintsRegistrar.java","lineNumber":42,"sourceCode":" * mybatis aot 运行时提示注册器\n *\n * @author xiaochen\n * @since 2026-01-12\n */\nclass MyBaitsRuntimeHintsRegistrar implements RuntimeHintsRegistrar {\n\n    @Override\n    public void registerHints(RuntimeHints hints, ClassLoader classLoader) {\n        AotUtils aotUtils = new AotUtils(hints, classLoader);\n        registerXml(aotUtils);\n    }\n\n    private void registerXml(AotUtils aotUtils) {\n        try {\n            aotUtils.registerPattern(aotUtils.findResources(\"\",\n                CollectUtils::isMapperXmlResource).toArray(AotUtils.EMPTY_STRING_ARRAY));\n        } catch (IOException e) {\n            throw new RuntimeException(\"注册用户资源目录的xml文件失败\", e);\n        }\n    }\n\n}\n","sourceCodeStart":24,"sourceCodeEnd":47,"githubUrl":"https://github.com/baomidou/mybatis-plus/blob/bf67d907478c724120bf76292da54abf9e73c2b3/spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/MyBaitsRuntimeHintsRegistrar.java#L24-L47","documentation":"Thrown by MyBaitsRuntimeHintsRegistrar (note the 'MyBaits' typo in the class name) in mybatis-plus-spring-boot-native-image: during GraalVM native-image AOT processing it scans the classpath for mapper XML resources via AotUtils.findResources and, on IOException, wraps it in RuntimeException('注册用户资源目录的xml文件失败' — failed to register xml files from user resource directories). It prevents building a native image whose resource hints would silently miss mapper XMLs.","triggerScenarios":"Compiling a Spring Boot app to a GraalVM native image with this module on the classpath, when the resource scan (classpath traversal for files matching CollectUtils.isMapperXmlResource) throws IOException — e.g. unreadable jars, exotic classloader schemes, or filesystem issues during native-image compilation.","commonSituations":"First native-image build of a MyBatis-Plus app; classpath containing jars in non-standard locations (fat jars, custom loaders); CI environments with restricted filesystem permissions; after upgrading Spring Boot AOT APIs.","solutions":["Check the wrapped IOException cause for which classpath entry failed to read; fix permissions or remove the offending jar/layout","Simplify the classpath for the native compile step (unpack/standard layout) so classloader resource traversal works","Ensure mapper XMLs are under standard/src/main/resources locations matched by the scan rather than generated in unusual places","If custom resource locations are needed, declare them explicitly via standard GraalVM resource hints (resource-config / @ImportRuntimeHints) instead of relying only on the scan"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before native compile, confirm mapper XMLs are discoverable as classpath resources\nEnumeration<URL> urls = getClass().getClassLoader().getResources(\"mapper\");\nwhile (urls.hasMoreElements()) {\n    URL u = urls.nextElement();\n    if (!\"file\".equals(u.getProtocol()) && !\"jar\".equals(u.getProtocol())) {\n        throw new IllegalStateException(\"Unsupported classpath protocol: \" + u);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    // native-image compile / AOT process run\n} catch (RuntimeException e) {\n    if (\"注册用户资源目录的xml文件失败\".equals(e.getMessage())) {\n        throw new IllegalStateException(\"AOT resource scan failed; check classpath readability\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Keep mapper XMLs in the application's own resources, not nested/shaded jars","Declare mapper patterns explicitly in GraalVM resource-config as a belt-and-braces measure","Run the AOT processing goal in CI early so classpath issues surface before full native compilation"],"tags":["mybatis-plus","graalvm","native-image","aot","resources"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}