简体   繁体   中英

Spring Boot Customizer for Javers

We are building a Spring Boot application with a PostgreSQL DB that uses Javers to generate an audit trail of user interactions with the app. We are relying on the auto-detection of Hibernates @Entity which works well for most cases, but for a few exceptions. For these cases we registrate the exceptional classes with JaversBuilder#registerEntities (on the advice of the documentation: https://javers.org/documentation/domain-configuration/#mapping-configuration ).

The problem with that is, that now the auto-configuration of Javers is overridden and thus the spring boot defaults no longer are applied. This results eg in a Javers in-memory repository instead of the SQL repository.

Is there a spring boot customizer available or planned that is able to override / set certain values and leaves the rest to spring boot? I thinking of something like Jackson2ObjectMapperBuilderCustomizer .

I just found the solution to my question. There is already some kind of customization, called JaversBuilderPlugin . To customize the configured spring boot instance of Javers you can provide a JaversBuilderPlugin like this:

  @Bean
  JaversBuilderPlugin customizeJavers() {
    return javersBuilder -> javersBuilder.registerEntity(ExceptionalClass.class);
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM