【问题标题】:Disable spring boot auditing in a jhipster generated application在 jhipster 生成的应用程序中禁用 Spring Boot 审计
【发布时间】:2015-08-01 13:30:00
【问题描述】:

我想在使用 jhipster 生成的应用程序中禁用/限制审计 (CustomAuditEventRepository)。

我该怎么做?

【问题讨论】:

    标签: jhipster spring-boot-actuator


    【解决方案1】:

    修改 CustomAuditEventRepository 使其在 add() 中不执行任何操作,这是生成的代码,它是你的,所以你可以用它做任何你想做的事情。

    【讨论】:

    • 我希望能够像记录日志一样从外部控制它。
    • 这是不可配置的,如果您认为应该可以,可以在我们的 github 项目上打开一个问题
    【解决方案2】:

    选项 1:禁用 spring actuator 的审计事件。将配置属性添加到application.yml 文件:

    management:
      auditevents:
        enabled: false
    

    参考:AuditAutoConfiguration

    @Configuration(proxyBeanMethods = false)
    @ConditionalOnBean(AuditEventRepository.class)
    @ConditionalOnProperty(prefix = "management.auditevents", name = "enabled", matchIfMissing = true)
    public class AuditAutoConfiguration {
    ...
    }
    

    选项 2:添加自定义 AuditListener bean

    @Bean
    public MyAuditListener auditListener() {
        return new MyAuditListener();
    }
    
    
    
    public class MyAuditListener extends AbstractAuditListener {
    
        private static final Log logger = LogFactory.getLog(MyAuditListener.class);
    
    
        public MyAuditListener() {
            ...
        }
    
        @Override
        protected void onAuditEvent(AuditEvent event) {
            ...
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 2018-04-15
      • 2021-08-19
      • 2017-10-07
      • 2016-07-16
      • 2017-12-21
      • 2017-11-06
      相关资源
      最近更新 更多