How to customise a jOOQ Configuration that is injected using Spring Boot – Java, SQL and jOOQ.

Related Articles

Starting with Spring Boot 2.5, there is a reusable and useful connection that you can implement, called DefaultConfigurationCustomizer, Where the word DefaultConfiguration corresponds to that of jOOQ DefaultConfiguration. You can simply create such a class in your project:

import org.jooq.conf.RenderQuotedNames;
import org.jooq.impl.DefaultConfiguration;
import org.springframework.boot.autoconfigure.jooq.*;
import org.springframework.context.annotation.*;

public class Config 
	public DefaultConfigurationCustomizer configurationCustomiser() 
		return (DefaultConfiguration c) -> c.settings()

The call back up gets the DefaultConfiguration In its initialization phase, during which you can still perform a safe mutation to change any of the defaults, or add additional settings, etc. This!

You can set a breakpoint within the lambda to verify when this boot is enabled:

Caused by: java.lang.RuntimeException
	at org.jooq.example.spring.Config.lambda$0(
	at org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration$DslContextConfiguration.lambda$jooqConfiguration$1(
	at java.base/$ForEachOp$OfRef.accept(
	at java.base/java.util.ArrayList.forEach(
	at java.base/$RefSortingSink.end(
	at java.base/$ChainedReference.end(
	at java.base/$ChainedReference.end(
	at java.base/
	at java.base/
	at java.base/$ForEachOp.evaluateSequential(
	at java.base/$ForEachOp$OfRef.evaluateSequential(
	at java.base/
	at java.base/
	at org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration$DslContextConfiguration.jooqConfiguration(
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.base/java.lang.reflect.Method.invoke(
	... 119 more

To play with this example, check out ours jOOQ-spring-boot-example on github.



Please enter your comment!
Please enter your name here

Popular Articles