Create a repository bean at runtime

I faced an issue can someone help?
I need to programmatically create a spring bean for a Neo4jRepository. It manage a generic class only known at runtime.
This is my repository definition :

public interface GeneratorRepository<P extends MyType>
        extends Neo4jRepository<P, Long>, CypherdslStatementExecutor<P>

And this is how I manage to create a bean :

DefaultListableBeanFactory springContextBeanFactory;
RootBeanDefinition beanDefinition = new RootBeanDefinition(GeneratorRepository.class);
                ResolvableType.forClassWithGenerics(GeneratorRepository.class, aMyTypeClassImpl));
        aMyTypeClassImpl.getSimpleName() + GeneratorRepository.class.getSimpleName(), beanDefinition);

After that, I can get the bean name with something like :

String[] name = springContextBeanFactory.getBeanNamesForType(
                        ResolvableType.forClassWithGenerics(GeneratorRepository.class, aMyTypeClassImpl));

And I get the name for the bean that was just created. But I get BeanCreationException when doing :


with message :
Failed to instantiate []: Specified class is an interface

The question is : is that possible to programmatically create a bean for an interface with generic and use it to get an Object?

Thank you for reading and for any help !