Skip to content

Commit d3886e3

Browse files
committed
Added formatter dependency to samples, turn warning into an error since the default value is false
1 parent 5a3f370 commit d3886e3

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public JdbcEventListener myListener() {
102102
This done by adding `RuntimeListenerSupportFactory` into P6Spy `modulelist`, overriding this property will cause to not registering factory thus listeners will not be applied
103103

104104
You can configure small set of parameters in your `application.properties`:
105+
> [!NOTE]
106+
> Configuration below indicates al possible parameters together with their default values and **does not** need to be set explicitly
105107
```properties
106108
# Register P6LogFactory to log JDBC events
107109
decorator.datasource.p6spy.enable-logging=true
@@ -180,6 +182,8 @@ public ConnectionIdManagerProvider connectionIdManagerProvider() {
180182
}
181183
```
182184
You can configure logging, query/slow query listeners and more using your `application.properties`:
185+
> [!NOTE]
186+
> Configuration below indicates al possible parameters together with their default values and **does not** need to be set explicitly
183187
```properties
184188
# One of logging libraries (slf4j, jul, common, sysout)
185189
decorator.datasource.datasource-proxy.logging=slf4j
@@ -199,7 +203,7 @@ decorator.datasource.datasource-proxy.multiline=true
199203

200204
# Formats the SQL for better readability. Uses Hibernate's formatter if present on the class path. If you opted in for a different JPA provider you need to add https://github.com/vertical-blank/sql-formatter as a runtime dependency to your app to enable this.
201205
# Mutually exclusive with json-format=true
202-
decorator.datasource.datasource-proxy.format-sql=true
206+
decorator.datasource.datasource-proxy.format-sql=false
203207
decorator.datasource.datasource-proxy.json-format=false
204208

205209
# Enable Query Metrics
@@ -234,6 +238,8 @@ All beans of type `ConnectionAcquiringStrategyFactory` are used to provide `Conn
234238
`EventListener<? extends Event>` beans can be registered to subscribe on events of flexy-pool (e.g. `ConnectionAcquireTimeThresholdExceededEvent`, `ConnectionLeaseTimeThresholdExceededEvent`).
235239

236240
You can configure your `FlexyPoolDataSource` by using bean `FlexyPoolConfigurationBuilderCustomizer` or properties:
241+
> [!NOTE]
242+
> Configuration below indicates al possible parameters together with their default values and **does not** need to be set explicitly
237243
```properties
238244
# Increments pool size if connection acquire request has timed out
239245
decorator.datasource.flexy-pool.acquiring-strategy.increment-pool.max-overflow-pool-size=15

datasource-decorator-spring-boot-autoconfigure/src/main/java/com/github/gavlyukovskiy/boot/jdbc/decorator/dsproxy/ProxyDataSourceBuilderConfigurer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void configure(ProxyDataSourceBuilder proxyDataSourceBuilder, DataSourceP
132132
if (formatQueryCallback != null) {
133133
proxyDataSourceBuilder.formatQuery(formatQueryCallback);
134134
} else {
135-
log.warn("formatSql requested but cannot be enabled because no formatter is present (neither Hibernate nor SqlFormatter).");
135+
throw new IllegalStateException("'datasource-proxy.format-sql' was set to 'true', but cannot be enabled because no formatter is present in the classpath (neither 'org.hibernate:hibernate-core' nor 'com.github.vertical-blank:sql-formatter').");
136136
}
137137
}
138138

samples/datasource-proxy-sample/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies {
2323

2424
implementation("com.h2database:h2")
2525
implementation("org.apache.commons:commons-io:1.3.2")
26+
implementation("com.github.vertical-blank:sql-formatter:2.0.4")
2627

2728
testImplementation("org.springframework.boot:spring-boot-starter-test")
2829
}

samples/datasource-proxy-sample/src/main/resources/application.yml

+6
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ spring:
1919
init:
2020
mode: never
2121

22+
decorator:
23+
datasource:
24+
datasource-proxy:
25+
format-sql: true
26+
query:
27+
log-level: INFO

0 commit comments

Comments
 (0)