Steps to reproduce:
- Define two interfaces
ObjectPostProcessor
andAuthorizationManager
public interface ObjectPostProcessor<T> {
void process(T t);
}
public interface AuthorizationManager<T> {
T getValue();
}
- SimpleStart as config class
public class SimpleStart implements ApplicationContextAware {
@Bean
static ObjectPostProcessor<Object> objectObjectPostProcessor(){
return o -> {
};
}
@Bean
static ObjectPostProcessor<AuthorizationManager<?>> authorizationManagerPostProcessor(){
return o -> {
};
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ResolvableType type = ResolvableType.forClassWithGenerics(ObjectPostProcessor.class, Object.class);
ObjectProvider<ObjectPostProcessor<Object>> postProcessors = applicationContext.getBeanProvider(type);
ObjectPostProcessor<Object> object = postProcessors.getObject();
System.out.println(object);
}
}
- Run
public class SpringTest {
@Test
public void research() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SimpleStart.class);
}
}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleStart': No qualifying bean of type 'cn.hiboot.framework.research.spring.research.ObjectPostProcessor<java.lang.Object>' available: expected single matching bean but found 2: objectObjectPostProcessor,authorizationManagerPostProcessor
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:608)
It does work well when I replaced ?
with Object
, I wonder if this scene needs to be supported in the future?
In Addition, I found that it was due to the change of #33982. But before that, it was good
Related to SEC#16299