spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support

Home Page:https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ProxyJCacheConfiguration ContextBootstrapInitializer Error

NightsiX opened this issue · comments

org.springframework.cache.jcache.config.ProxyJCacheConfiguration
ContextBootstrapInitializer Error

gen code:

  public static void registerProxyJCacheConfiguration(DefaultListableBeanFactory beanFactory) {
    BeanDefinitionRegistrar.of("org.springframework.cache.jcache.config.ProxyJCacheConfiguration", ProxyJCacheConfiguration.class)
        .instanceSupplier((instanceContext) -> {
          ProxyJCacheConfiguration bean = new ProxyJCacheConfiguration();
          instanceContext.method("setConfigurers", ObjectProvider.class)
              .invoke(beanFactory, (attributes) -> bean.setConfigurers(attributes.get(0)));
          return bean;
        }).customize((bd) -> bd.setRole(2)).register(beanFactory);
  }

the gen class package is org.springframework.cache.annotation can't invoke ProxyJCacheConfiguration's setConfigurers method

How to solve this problem😢

spring boot version 2.7.1 native version 0.12.1

the class all code:

package org.springframework.cache.annotation;

import org.springframework.aot.beans.factory.BeanDefinitionRegistrar;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.cache.jcache.config.ProxyJCacheConfiguration;

public final class ContextBootstrapInitializer {
  public static void registerProxyCachingConfiguration(DefaultListableBeanFactory beanFactory) {
    BeanDefinitionRegistrar.of("org.springframework.cache.annotation.ProxyCachingConfiguration", ProxyCachingConfiguration.class)
        .instanceSupplier((instanceContext) -> {
          ProxyCachingConfiguration bean = new ProxyCachingConfiguration();
          instanceContext.method("setConfigurers", ObjectProvider.class)
              .invoke(beanFactory, (attributes) -> bean.setConfigurers(attributes.get(0)));
          return bean;
        }).customize((bd) -> bd.setRole(2)).register(beanFactory);
  }

  public static void registerProxyJCacheConfiguration(DefaultListableBeanFactory beanFactory) {
    BeanDefinitionRegistrar.of("org.springframework.cache.jcache.config.ProxyJCacheConfiguration", ProxyJCacheConfiguration.class)
        .instanceSupplier((instanceContext) -> {
          ProxyJCacheConfiguration bean = new ProxyJCacheConfiguration();
          instanceContext.method("setConfigurers", ObjectProvider.class)
              .invoke(beanFactory, (attributes) -> bean.setConfigurers(attributes.get(0)));
          return bean;
        }).customize((bd) -> bd.setRole(2)).register(beanFactory);
  }
}

Spring Native is now superseded by Spring Boot 3 official native support, see the related reference documentation for more details.

As a consequence, I am closing this issue, and recommend trying your use case with latest Spring Boot 3 version. If you still experience the issue reported here, please open an issue directly on the related Spring project (Spring Framework, Data, Security, Boot, Cloud, etc.) with a reproducer.

Thanks for your contribution on the experimental Spring Native project, we hope you will enjoy the official native support introduced by Spring Boot 3.