@ Beans configurables que no funcionan con JPA-EntityListeners en Spring Boot

Tengo un problema extraño con un oyente personalizado jpa-entity que he creado en una aplicación de arranque de primavera. Estoy tratando de usar Springs@Configurable mecanismo para configurar EntityListener (como se ve en SpringsAuditingEntityListener) pero Spring se niega a reconocer mi oyente tan pronto como se usa en el@EntityListeners-Anotación en una entidad jpa. si no está configurado en una entidad jpa, Spring escucha y configura Spring Listener como debería.

He creado un proyecto de ejemplo con una prueba junit para demostrar el problema:https://github.com/chrisi/aopconfig/find/master

@SpringBootApplication
@EnableSpringConfigured
@EnableLoadTimeWeaving
public class Application {

  public static void main(String[] args) throws Exception {
    SpringApplication.run(Application.class, args);
  }
}

El EntityListener:

/**
 * This bean will NOT be instanciated by Spring but it should be configured by Spring
 * because of the {@link Configurable}-Annotation.
 * <p>
 * The configuration only works if the <code>UnmanagedBean</code> is not used as an <code>EntityListener</code>
 * via the {@link javax.persistence.EntityListeners}-Annotation.
 *
 * @see FooEntity
 */
@Configurable
public class UnmanagedBean {

  @Autowired
  private ManagedBean bean;

  public int getValue() {
    return bean.getValue();
  }
}

El Bean que quiero que se inyecte en EntityListener / UnmanagedBean:

/**
 * This bean will be instanciated/managed by Spring and will be injected into the
 * {@link UnmanagedBean} in the case the <code>UnmanagedBean</code> is not used as an JPA-EntityListener.
 */
@Component
@Data
public class ManagedBean {
  private int value = 42;
}

La entidad donde se debe usar el oyente:

/**
 * This simple entity's only purpose is to demonstrate that as soon as
 * it is annotated with <code>@EntityListeners({UnmanagedBean.class})</code>
 * springs configurable mechanism will not longer work on the {@link UnmanagedBean}
 * and therefore the <code>ConfigurableTest.testConfigureUnmanagedBean()</code> fails.
 */
@Entity
@EntityListeners({UnmanagedBean.class}) // uncomment to make the test fail
public class FooEntity {

  @Id
  private Long id;

  private String bar;
}

Y, finalmente, la prueba que muestra que el cableado no funciona tan pronto como se utiliza el oyente:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
public class ConfigurableTest {

  /**
   * This test checks if the ManagedBean was injected into the UnmanagedBean
   * by Spring after it was created with <code>new</code>
   */
  @Test
  public void testConfigureUnmanagedBean() {
    UnmanagedBean edo = new UnmanagedBean();
    int val = edo.getValue();
    Assert.assertEquals(42, val);
  }
}

La prueba junit (el cableado de EntityListener / ManagedBean) falla tan pronto como la anotación@EntityListeners({UnmanagedBean.class}) enFooEntity Está activado.

¿Es esto un error o me perdí algo más?

Para ejecutar la prueba tienes que usar-javaagent:spring-instrument-4.1.6.RELEASE.jar en la línea de comando y proporcione el archivo jar en el directorio de trabajo.

Esta es la versión "condensada" de una pregunta que hice antes:@Configurable no reconocido en la aplicación SpringBoot

Respuestas a la pregunta(0)

Su respuesta a la pregunta