我想在 spring boot 中通过 p6spy 显示 sql 参数,因为 hibernate 显示的 sql 参数非常庞大。但由于某种原因,p6spy 记录器输出 sql 消息两次,尽管实际上对 db 的查询执行一次。通常的 spring 应用程序可以正常使用我的 p6spy 配置。Spring Boot 应用程序可以正常使用休眠输出。spy.properties:driverlist=org.postgresql.Driverappender=com.p6spy.engine.spy.appender.Slf4JLoggerlogMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormatcustomLogMessageFormat=time %(executionTime)|con %(connectionId)|%(sqlSingleLine)log4j2.xml:<?xml version="1.0" encoding="UTF-8"?><Configuration status="WARN"> <Properties> <Property name="layoutPattern"> %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n </Property> </Properties><Appenders> <Console name="stdout"> <PatternLayout pattern="${layoutPattern}"/> </Console></Appenders><Loggers> <Root level="info"> <AppenderRef ref="stdout" /> </Root></Loggers></Configuration>休眠配置:@Configuration@EnableTransactionManagementpublic class HibernateConfig {@Beanpublic LocalSessionFactoryBean getSessionFactory(){ LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setPackagesToScan("bel.rdigital.p6spy.boot.test.model"); Properties hibernateProperties = new Properties(); hibernateProperties.setProperty(DIALECT, "org.hibernate.dialect.PostgreSQLDialect"); hibernateProperties.setProperty(HBM2DDL_AUTO, "create"); hibernateProperties.setProperty(SHOW_SQL, "true");}我期望一个 sql 输出,但得到两个具有不同 p6spy 连接的相似 sql 输出:1) p6spy - time 1|con 2|insert into serverstartups (applicationName, hostName, ip, startDate, stopDate, startupId) 值 ('', 'DIMON-LAPTOP', '192.168.88.244', '2019-02-11T12: 00:46.989+0300',空值,1)2) p6spy - time 1|con 5|insert into serverstartups (applicationName, hostName, ip, startDate, stopDate, startupId) 值 ('', 'DIMON-LAPTOP', '192.168.88.244', '2019-02-11T12: 00:46.989+0300',空值,1)如您所见,除了连接(2 和 5)之外,这些输出是相似的
添加回答
举报
0/150
提交
取消