spring boot 2.2
Comment From: cielswift
@Autowired private AutowireCapableBeanFactory capableBeanFactory;
capableBeanFactory.autowireBean(new Msg("AA"))
capableBeanFactory.getBean(Msg.class) No qualifying bean of type 'com.ciel.springcloudfathernewconfigclient.stream.Msg' available
Comment From: wilkinsona
As indicated by the code not being in the org.springframework.boot
package, AutowireCapableBeanFactory
isn't part of Spring Boot. It is an API that's provided by Spring Framework. As such, this isn't the correct issue tracker to use.
If you read the javadoc for autowireBean(Object)
you can see that it will "populate the given bean instance through applying after-instantiation callbacks and bean property post-processing (e.g. for annotation-driven injection)." It does not register a bean with the bean factory. If you want to register an instance that you have created, you probably want to use registerSingleton(String, Object)
instead.
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing and in issues that you have raised previously, we prefer to use GitHub issues only for bugs and enhancements.