{"record":{"id":"596f4f7460afbdf5","repo":"baomidou/mybatis-plus","slug":"xml-596f4f","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/MyBatisPlusNativeImageConfiguration.java","lineNumber":97,"sourceCode":"    @Bean\n    static MyBatisMapperFactoryBeanPostProcessor myBatisMapperFactoryBeanPostProcessor() {\n        return new MyBatisMapperFactoryBeanPostProcessor();\n    }\n\n    static class MyBatisRuntimeHintsRegistrar 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\n    static class MyBatisBeanFactoryInitializationAotProcessor\n        implements BeanFactoryInitializationAotProcessor, BeanRegistrationExcludeFilter {\n\n        private final Set<Class<?>> excludeClasses = new HashSet<>();\n\n        MyBatisBeanFactoryInitializationAotProcessor() {\n            excludeClasses.add(MapperScannerConfigurer.class);\n        }\n\n        @Override\n        public boolean isExcludedFromAotProcessing(RegisteredBean registeredBean) {\n            return excludeClasses.contains(registeredBean.getBeanClass());\n        }","sourceCodeStart":79,"sourceCodeEnd":115,"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/MyBatisPlusNativeImageConfiguration.java#L79-L115","documentation":"Thrown by the nested RuntimeHintsRegistrar inside MyBatisPlusNativeImageConfiguration: identical logic to MyBaitsRuntimeHintsRegistrar — it registers mapper XML resource patterns for GraalVM native images and wraps any IOException from AotUtils.findResources in RuntimeException('注册用户目录的xml文件失败' — failed to register xml files from user directories). This variant is the inner registrar used by the auto-configuration class.","triggerScenarios":"Building a native image with mybatis-plus-spring-boot-native-image auto-configuration active; during AOT processing the classpath scan for resources matching CollectUtils.isMapperXmlResource throws IOException (unreadable nested jars, unusual protocols, filesystem errors).","commonSituations":"Native-image builds in CI with restrictive file permissions; Spring Boot versions whose LaunchedURLClassLoader resource enumeration behaves differently; multi-module builds packaging mapper XMLs in shaded or nested jars.","solutions":["Inspect the cause IOException to identify the unreadable classpath entry and fix packaging/permissions","Keep mapper XMLs in plain resource directories of the application jar rather than nested/shaded jars","Fall back to explicit GraalVM resource configuration (META-INF/native-image/.../resource-config.json listing mapper/**/*.xml)","Match the Spring Boot / GraalVM plugin versions certified with this starter version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Sanity-check classloader resource enumeration before AOT processing\nClassLoader cl = Thread.currentThread().getContextClassLoader();\nEnumeration<URL> urls = cl.getResources(\"\");\nwhile (urls.hasMoreElements()) {\n    URL u = urls.nextElement();\n    try { new java.io.File(u.toURI()).canRead(); }\n    catch (Exception ex) { throw new IllegalStateException(\"Unreadable classpath entry: \" + u, ex); }\n}","typeGuard":null,"tryCatchPattern":"try {\n    // native-image build with auto-configuration active\n} catch (RuntimeException e) {\n    if (\"注册用户目录的xml文件失败\".equals(e.getMessage())) {\n        throw new IllegalStateException(\"Native-image AOT mapper XML scan failed\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Use standard Spring Boot packaging (no exotic shading) for native builds","Pin Spring Boot and mybatis-plus starter versions that are tested together for native support","List mapper XML patterns in META-INF/native-image resource-config.json explicitly"],"tags":["mybatis-plus","graalvm","native-image","aot","autoconfiguration"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}