2

I am trying to write a custom JPA-EntityListener for my spring boot app which is somehow application-context aware. while reading the docs to find out how to accomplish that I stumbled across the AuditingEntityListener that is shipped with spring-data and the @Configurable Annotation that is also used in this Listener which enables the configuration of objects that are not managed by spring. So I tried to use it in my own Listener but there the annotation would not be recognized. I already read the docs and many posts about this topic but some of them seemed to be quite outdated. Thats why I'm asking here:

Do I have to specify the spring-instrument.jar for LoadTimeWeaving in any case? The spring docs say that there are other ways and it is also possible to configure it (per classloader?) in the application-context. but when I start my app with @EnableLoadTimeWeaving without specifiying the agent on the command-line I get an error.

I am wondering why the AuditingEntityListener is recognized on startup even in applications where neither @EnableLoadTimeWeaving nor @EnableSpringConfigured is specified. Is it because the distributed spring-jars are already compiled with CTW?

I also tried CompileTimeWeaving but that conflicted with lombok. I found a solution/workaround for that from 2011 but that didn't work for me. Is there a way to do that?

What are the advantages and disadvantages of LTW and CTW and waht is the best way to implement the custom ApplicationContext-aware JPAEntityListener?

gofrm
  • 364
  • 2
  • 15

0 Answers0