在搭建微服务的过程中,发现控制台一直在报这个警告日志。本着研究的目的,查看了下源码

[WARN][JpaBaseConfiguration$JpaWebConfiguration][219]: spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
    @Bean
    public OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor() {
        if (this.jpaProperties.getOpenInView() == null) {
            logger.warn("spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning");
        }

        return new OpenEntityManagerInViewInterceptor();
    }

因此,只需要设置open_in_view设置初始值即可:

spring:
  jpa:
    open-in-view: false    

这样启动就不会报告警了。

新建公众号:随风的java开发人生 共同进步。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐