Springboot 集成 Ehcache操作数据库显示SQL语句设置
2023-09-1323:33:35.030 INFO6124---[task-1]o.hibernate.jpa.internal.util.LogHelper:HHH000204: Processing PersistenceUnitInfo[name: default]2023-09-1323:33:35.124 INFO6124---[task-1]org.hibernate.Version:HHH000412: Hibernate ORM core version5.4.20.Final2023-09-1323:33:35.137 WARN6124---[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 warning2023-09-1323:33:35.380 INFO6124---[task-1]o.hibernate.annotations.common.Version:HCANN000001: Hibernate Commons Annotations{5.1.0.Final}2023-09-1323:33:35.572 INFO6124---[task-1]org.hibernate.dialect.Dialect:HHH000400: Using dialect: org.hibernate.dialect.MySQL57Dialect2023-09-1323:33:35.621 WARN6124---[main]ion$DefaultTemplateResolverConfiguration:Cannotfindtemplate location: classpath:/templates/(pleaseaddsome templates or check your Thymeleaf configuration)2023-09-1323:33:35.819 INFO6124---[main]o.s.b.w.embedded.tomcat.TomcatWebServer:Tomcat started on port(s):8081(http)with context path'/ehcache'2023-09-1323:33:35.821 INFO6124---[main]DeferredRepositoryInitializationListener:Triggering deferred initialization of Spring Data repositories…2023-09-1323:33:36.410 INFO6124---[task-1]o.h.e.t.j.p.i.JtaPlatformInitiator:HHH000490: Using JtaPlatform implementation:[org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]2023-09-1323:33:36.420 INFO6124---[task-1]j.LocalContainerEntityManagerFactoryBean:Initialized JPA EntityManagerFactoryforpersistence unit'default'2023-09-1323:33:36.670 INFO6124---[main]DeferredRepositoryInitializationListener:Spring Data repositories initialized!2023-09-1323:33:36.681 INFO6124---[main]org.bc.device.EhcacheApplication:Started EhcacheApplicationin6.344seconds(JVM runningfor7.048)2023-09-1323:33:42.253 INFO6124---[nio-8081-exec-1]o.a.c.c.C.[.[localhost].[/ehcache]:Initializing Spring DispatcherServlet'dispatcherServlet'2023-09-1323:33:42.254 INFO6124---[nio-8081-exec-1]o.s.web.servlet.DispatcherServlet:Initializing Servlet'dispatcherServlet'2023-09-1323:33:42.264 INFO6124---[nio-8081-exec-1]o.s.web.servlet.DispatcherServlet:Completed initializationin10ms2023-09-1323:33:42.305 INFO6124---[nio-8081-exec-1]o.b.d.controller.EmployeeController:findAll请求时间:2023-09-13T23:33:42.3056641002023-09-1323:33:42.310 INFO6124---[nio-8081-exec-1]org.bc.device.config.EhcacheConfig:ehcache key str: org.bc.device.service.EmployeeService:findAll2023-09-1323:33:42.312 INFO6124---[nio-8081-exec-1]org.bc.device.config.EhcacheConfig:ehcache key md5DigestAsHex: 363a29df59ef3a5e8c7fbae68bbdb2132023-09-1323:33:42.314 INFO6124---[nio-8081-exec-1]org.bc.device.config.EhcacheConfig:ehcache key str: org.bc.device.service.EmployeeService:findAll2023-09-1323:33:42.314 INFO6124---[nio-8081-exec-1]org.bc.device.config.EhcacheConfig:ehcache key md5DigestAsHex: 363a29df59ef3a5e8c7fbae68bbdb2132023-09-1323:33:42.323 INFO6124---[nio-8081-exec-1]org.bc.device.service.EmployeeService:findAll查询数据库 Hibernate:selecttbinfemplo0_.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-1323:33:42.590 INFO6124---[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-1323:33:42.613 INFO6124---[nio-8081-exec-1]o.b.d.controller.EmployeeController:findAll返回时间:2023-09-13T23:33:42.613281300server: port:8081servlet: 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=5initialSize:5minIdle:5maxActive:20cache: type: ehcache ehcache: config: classpath:/ehcache.xml jpa: properties: hibernate: format_sql:trueshow_sql:true配置如下:
jpa:
properties:
hibernate:
format_sql: true
show_sql: true