美文网首页
springBoot 启动卡顿

springBoot 启动卡顿

作者: HelloWide | 来源:发表于2019-03-28 15:46 被阅读0次

某次在内网(无互联网访问),centos7.3 tomcat7部署boot war包是发现,应用每次卡在:
[ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect,时长达10多分钟,使用idea启动boot内嵌tomcat启动时打印如下:

2018-11-27 10:58:39.542 INFO 10488 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2018-11-27 10:58:47.689  INFO 10488 --- [  restartedMain] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException

研究发现,boot-start包内部嵌套了hibernate,Hibernate默认是使用jdbc方式来取的,而工程使用的是mybatis+druid方式,jdbc自然获取不到连接;通过在application.properties配置:

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false

即可跳过jdbc hibernate连接,测试验证后再linux环境下启动无卡顿;

boot简单灵活性建立在封装了多种常用组件基础之上,例如hibernate jpa核心服务,该问题切入点可以查看

package org.hibernate.engine.jdbc.env.internal;

...

public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEnvironment> {

@Override

public JdbcEnvironment initiateService(Map configurationValues, ServiceRegistryImplementor registry) {

  final DialectFactory dialectFactory = registry.getService( DialectFactory.class );

  // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.

// The need for it is intended to be alleviated with future development, thus it is

// not defined as an Environment constant...

//

// it is used to control whether we should consult the JDBC metadata to determine

// certain Settings default values; it is useful to *not* do this when the database

// may not be available (mainly in tools usage).

  boolean useJdbcMetadata = ConfigurationHelper.getBoolean(

        "hibernate.temp.use_jdbc_metadata_defaults",

        configurationValues,

true
 );

...
相关调用链分析可以提供IDE分析即可;
也可以通过springboot删除hibernate服务:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
  <!--排除Hibernate相关依赖-->
  <exclusions>
    <exclusion>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
    </exclusion>
  </exclusions>
</dependency>

相关文章

  • springBoot 启动卡顿

    某次在内网(无互联网访问),centos7.3 tomcat7部署boot war包是发现,应用每次卡在:[ re...

  • 应用卡顿问题分析

    1.应用卡顿原理分析 卡顿问题的表现启动卡顿:启动白屏和启动动画卡顿运行卡顿:点击相应慢,列表滑动卡,动画卡顿 原...

  • iOS 性能优化

    iOS的性能优化主要可提现在以前的几个方面:卡顿优化、耗电优化、启动优化、安装包的瘦身。 1、卡顿优化 在了解卡顿...

  • iOS底层原理之性能优化

    文章目录 CPU和GPU 卡顿优化 - CPU 卡顿优化 - GPU 离屏渲染 耗电 耗电优化 APP的启动 AP...

  • iOS---性能优化

    项目中影响性能的主要有一下几方面:卡顿、耗电、网络、启动优化 一、卡顿 造成卡顿的原因是发生vsyn信号时,GPU...

  • iOS-面试题5-性能优化

    目录: 卡顿优化 耗电优化 启动优化 APP瘦身 一. 卡顿优化 CPU和GPU的作用CPU计算文字大小、位置、颜...

  • iOS底层原理--性能优化

    文章目录CPU和GPU 卡顿优化 - CPU 卡顿优化 - GPU 离屏渲染 耗电耗电优化 APP的启动 APP启...

  • iOS底层原理之性能优化

    文章目录CPU和GPU 卡顿优化 - CPU 卡顿优化 - GPU 离屏渲染 耗电耗电优化 APP的启动 APP启...

  • 一. Android 启动时间优化

    1)启动页白屏及黑屏解决?2)启动太慢怎么解决?3)怎么保证应用启动不卡顿?4)App启动崩溃异常捕捉5)统计启动...

  • SpringBoot启动源码解读

    最近看springBoot,研究一下springBoot启动源码 springboot启动 初始化SpringAp...

网友评论

      本文标题:springBoot 启动卡顿

      本文链接:https://www.haomeiwen.com/subject/luaqbqtx.html