Springboot 集成 Ehcache操作数据库显示SQL语句设置

Springboot 集成 Ehcache操作数据库显示SQL语句设置

bash 复制代码
2023-09-13 23:33:35.030  INFO 6124 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-09-13 23:33:35.124  INFO 6124 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.20.Final
2023-09-13 23:33:35.137  WARN 6124 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : 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
2023-09-13 23:33:35.380  INFO 6124 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2023-09-13 23:33:35.572  INFO 6124 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL57Dialect
2023-09-13 23:33:35.621  WARN 6124 --- [           main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2023-09-13 23:33:35.819  INFO 6124 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path '/ehcache'
2023-09-13 23:33:35.821  INFO 6124 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories...
2023-09-13 23:33:36.410  INFO 6124 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-09-13 23:33:36.420  INFO 6124 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-09-13 23:33:36.670  INFO 6124 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2023-09-13 23:33:36.681  INFO 6124 --- [           main] org.bc.device.EhcacheApplication         : Started EhcacheApplication in 6.344 seconds (JVM running for 7.048)
2023-09-13 23:33:42.253  INFO 6124 --- [nio-8081-exec-1] o.a.c.c.C.[.[localhost].[/ehcache]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-09-13 23:33:42.254  INFO 6124 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-09-13 23:33:42.264  INFO 6124 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 10 ms
2023-09-13 23:33:42.305  INFO 6124 --- [nio-8081-exec-1] o.b.d.controller.EmployeeController      : findAll请求时间:2023-09-13T23:33:42.305664100
2023-09-13 23:33:42.310  INFO 6124 --- [nio-8081-exec-1] org.bc.device.config.EhcacheConfig       : ehcache key str: org.bc.device.service.EmployeeService:findAll
2023-09-13 23:33:42.312  INFO 6124 --- [nio-8081-exec-1] org.bc.device.config.EhcacheConfig       : ehcache key md5DigestAsHex: 363a29df59ef3a5e8c7fbae68bbdb213
2023-09-13 23:33:42.314  INFO 6124 --- [nio-8081-exec-1] org.bc.device.config.EhcacheConfig       : ehcache key str: org.bc.device.service.EmployeeService:findAll
2023-09-13 23:33:42.314  INFO 6124 --- [nio-8081-exec-1] org.bc.device.config.EhcacheConfig       : ehcache key md5DigestAsHex: 363a29df59ef3a5e8c7fbae68bbdb213
2023-09-13 23:33:42.323  INFO 6124 --- [nio-8081-exec-1] org.bc.device.service.EmployeeService    : findAll查询数据库
Hibernate: 
    select
        tbinfemplo0_.id as id1_0_,
        tbinfemplo0_.age as age2_0_,
        tbinfemplo0_.department as departme3_0_,
        tbinfemplo0_.hire_date as hire_dat4_0_,
        tbinfemplo0_.emp_name as emp_name5_0_,
        tbinfemplo0_.salary as salary6_0_ 
    from
        tb_inf_employee tbinfemplo0_
2023-09-13 23:33:42.590  INFO 6124 --- [nio-8081-exec-1] o.b.d.controller.EmployeeController      : findAll返回结果:[TbInfEmployee(id=1, name=1, age=1, salary=1.0, department=1, hireDate=2023-09-13), TbInfEmployee(id=2, name=1, age=1, salary=1.0, department=1, hireDate=2023-09-13), TbInfEmployee(id=3, name=1, age=1, salary=1.0, department=1, hireDate=2023-09-13), TbInfEmployee(id=4, name=1, age=1, salary=1.0, department=1, hireDate=2023-09-13), TbInfEmployee(id=5, name=1, age=1, salary=1.0, department=1, hireDate=2023-09-13), TbInfEmployee(id=6, name=1, age=1, salary=11.0, department=1, hireDate=2023-09-13)]
2023-09-13 23:33:42.613  INFO 6124 --- [nio-8081-exec-1] o.b.d.controller.EmployeeController      : findAll返回时间:2023-09-13T23:33:42.613281300
bash 复制代码
server:
  port: 8081
  servlet:
    context-path: /ehcache

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    username: root
    password: 
    url: jdbc:mysql://127.0.0.1:3306/test_ehcache?characterEncoding=utf8&useUnicode=true&useSSL=false&zeroDateTimeBehavior=convertToNull&autoReconnect=true&allowMultiQueries=true&failOverReadOnly=false&connectTimeout=6000&maxReconnects=5
    initialSize: 5
    minIdle: 5
    maxActive: 20
  cache:
    type: ehcache
    ehcache:
      config: classpath:/ehcache.xml
  jpa:
    properties:
      hibernate:
        format_sql: true
        show_sql: true

配置如下:

jpa:

properties:

hibernate:

format_sql: true

show_sql: true

相关推荐
灰原喜欢柯南1 小时前
OceanBase 运维管理知识点——OCP 监控、诊断与变更控制
数据库·oceanbase
仍然.1 小时前
Redis---事务
数据库·redis
oradh1 小时前
Oracle 执行计划的阅读方法(二叉树结构来理解和阅读)
数据库·oracle·执行计划的阅读方法
SelectDB1 小时前
Doris 向量检索上线踩坑记录:七个排查现场与可直接复制的命令
大数据·数据库·数据分析
数据库小学妹1 小时前
MySQL深分页优化:LIMIT大偏移的根因分析与五种解法对比
数据库·mysql·性能优化
SelectDB1 小时前
一条大查询把集群打挂之后:Apache Doris 稳定性处置与资源隔离速查
大数据·数据库·数据分析
钱栈up1 小时前
全量 21 个失败、单跑全绿:泄漏进连接池的 SQL 变量
sql·单元测试·测试
这个DBA有点耶1 小时前
数据库部署架构深潜:集中式、分布式、云原生的技术原理、演进逻辑与选型框架
数据库·架构