Giriş
Açıklaması şöyle
Registering classes for which you want to use reflection is just as easy, you either use @RegisterReflectionForBinding annotation or you can do the same through the RuntimeHintsRegistrar with more flexible configuration:Moreover, you can use the @RegisterReflectionForBinding annotation anywhere (services, methods and etc.), but we decided to use only the RuntimeHintsRegistrar to contain all the AOT configurations in one place and not search through the code.
Örnek
Jackson için şöyle yaparız
@RegisterReflectionForBinding({MyClass.class, MyClass2.class})
Şöyle yaparız
@Configuration @RegisterReflectionForBinding({CustomMessage.class, CustomMessage.Status.class}) @ImportRuntimeHints(AppConfiguration.AppRuntimeHintsRegistrar.class) public class AppConfiguration { public static class AppRuntimeHintsRegistrar implements RuntimeHintsRegistrar { @Override public void registerHints(RuntimeHints hints, ClassLoader classLoader) { hints.reflection() .registerType( CustomMessage.class, PUBLIC_FIELDS, INVOKE_PUBLIC_METHODS, INVOKE_PUBLIC_CONSTRUCTORS ).registerType( CustomMessage.Status.class, PUBLIC_FIELDS, INVOKE_PUBLIC_METHODS, INVOKE_PUBLIC_CONSTRUCTORS ); } } }
Hiç yorum yok:
Yorum Gönder