在遵循各种示例和阅读spring boot文档后,我仍然无法启用Hibernate统计信息。 我在application.properties文件中设置了属性。 通过集成测试或Application.java运行spring boot应用程序不会生成任何统计信息。
我的application.properties文件如下。
spring.datasource.jdbcUrl=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username = postgres
spring.datasource.password = password
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.generate_statistics=true
logging.level.org.hibernate.SQL=TRACE
logging.level.org.hibernate.stat=TRACE
logging.file=transaction-app.log
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="FILE" />
</root>
</configuration>
我的集成测试
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SqlMappingTest {
@Autowired
PlanService planService;
@org.junit.Test
public void findAll() {
List<Plan> plans = planService.findAll();
Assert.assertEquals(1, plans.size());
}
}
我错过了什么?