First pitfall

When you call the ListableBeanFactory.getBeansOfType() method, you cannot be sure which beans will be returned. Let's look at the code of the getBeansOfType() method in the DefaultListableBeanFactory.java class:

@Override@SuppressWarnings("unchecked")public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)      throws BeansException {        ......          if (exBeanName != null && isCurrentlyInCreation(exBeanName)) {        if (this.logger.isDebugEnabled()) {          this.logger.debug("Ignoring match to currently created bean           '" +           exBeanName + "': " +          ex.getMessage());        }        onSuppressedException(ex);        // Ignore: indicates a circular reference when auto wiring         constructors. // We want to find matches ...

Get Hands-On High Performance with Spring 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.