shellyxue commented on issue #1007:
URL: https://github.com/apache/dubbo-samples/issues/1007#issuecomment-2328264699

   添加下面代码到工程中,可以解决这个问题:
   
   ```
   @Configuration(proxyBeanMethods = false)
   @ConditionalOnClass(name = "org.apache.dubbo.rpc.Protocol$Adaptive")
   
@ImportRuntimeHints(DubboHintsConfiguration.CustomRuntimeHintsRegistrar.class)
   public class DubboHintsConfiguration {
       public static class CustomRuntimeHintsRegistrar implements 
RuntimeHintsRegistrar {
           private static final String BASE_PACKAGES = "org.apache.dubbo";
           private static final String FILTER_SUFFIX = "/**/*$Adaptive.class";
   
           @Override
           @SuppressWarnings("unchecked")
           public void registerHints(RuntimeHints hints, @Nullable ClassLoader 
classLoader) {
               try {
                   //注册Adaptive类对象
                   ResourcePatternResolver resourcePatternResolver = new 
PathMatchingResourcePatternResolver();
                   MetadataReaderFactory metadataReaderFactory = new 
CachingMetadataReaderFactory(resourcePatternResolver);
   
                   String packageSearchPath = 
ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
                           + 
ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(BASE_PACKAGES))
                           + FILTER_SUFFIX;
                   Resource[] resources = 
resourcePatternResolver.getResources(packageSearchPath);
                   Arrays.stream(resources).forEach(x -> {
                       try {
                           MetadataReader metadataReader = 
metadataReaderFactory.getMetadataReader(x);
                           Class<?> clazz = 
Class.forName(metadataReader.getClassMetadata().getClassName());
                           hints.reflection().registerType(clazz, 
MemberCategory.values());
                       } catch (Throwable ignored) {
   
                       }
                   });
               } catch (Throwable ignored) {
   
               }
   
           }
       }
   
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to