【发布时间】:2021-12-12 08:25:06
【问题描述】:
我们使用 EclipseLink 作为我们的 JPA 提供者。
我在网上找到了很多关于persistence.xml 解决方案的答案,但我实际上是在尝试避免使用 XML 配置。我什至读到 SpringBoot 现在甚至不再查找该文件,除非被告知。为此,我想尽量坚持application.properties。
似乎 Hibernate 通过传递 spring.jpa.hibernate 属性获得了不错的支持。然而,当谈到 EclipseLink 时,我就束手无策了。
我正在尝试:
- 将 EclipseLink 日志设置为
ALL以帮助我进行调试。 - 激活 EclipseLink Batch-Writing 看看我是否可以提高我的应用程序的性能。
这是我目前的application.properties:
logging.level.root=info
spring.jpa.show-sql=true
eclipselink.jdbc.batch-writing=JDBC
eclipselink.jdbc.batch-writing.size=500
我尝试将some of these answers 的值插入application.properties,但它并没有真正帮助我查看SQL 命令。我可以看到一些 SQL 的唯一方法是使用 spring.jpa.show-sql=true,这让我相信它并不像我期望避免使用 persistence.xml 那样微不足道。这也让我怀疑 eclipselink.jdbc.batch-writing 属性实际上也没有被 EclipseLink 识别。
我们确实通过logback 登录。也许这个logback.xml 文件内容可能会有所帮助:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="2 seconds" debug="false">
<appender name="log.console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="com.foo.bar.app.LoggerLayoutEncoder">
<pattern>%d{HH:mm:ss.SSSS} -\t%highlight(%-5level)\t%17.-17tenantContext\t%15.-15userContext\t%50.-50requestContext\tThread[%26.-26thread]%n\t\t\t\tLogger[%green(%36.36(%logger{36}))]\tMsg[%highlight(%msg)]%n</pattern>
</encoder>
</appender>
<appender name="Sentry" class="io.sentry.logback.SentryAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="log.console" />
<appender-ref ref="Sentry" />
</root>
</configuration>
【问题讨论】:
标签: java spring spring-boot jpa eclipselink