title: Injecting a Spring dependency into a JPA EntityListener
body: <p>I am trying <strong>to inject a Spring dependency</strong> into an <strong>JPA EntityListener</strong>. Here is my listener class:</p>
  
  <pre><code>@Configurable(autowire = Autowire.BY_TYPE, dependencyCheck = true)
  public class PliListener {
  
      @Autowired
      private EvenementPliRepository evenementPliRepository;
  
      @PostPersist
      void onPostPersist(Pli pli) {
          EvenementPli ev = new EvenementPli();
          ev.setPli(pli);
          ev.setDateCreation(new Date());
          ev.setType(TypeEvenement.creation);
          ev.setMessage("Création d'un pli");
          System.out.println("evenementPliRepository: " + evenementPliRepository);
          evenementPliRepository.save(ev);
      }
  
  
  }
  </code></pre>
  
  <p>Here is my Entity class:</p>
  
  <pre><code>@RooJavaBean
  @RooToString
  @RooJpaActiveRecord
  @EntityListeners(PliListener.class)
  public class Pli implements Serializable{
  ...
  </code></pre>
  
  <p>However, my dependency (i.e. <code>evenementPliRepository</code>) <strong>is always null</strong>.</p>
  
  <p>Can anyone please help?</p>