Sniffy is a cool little project:
Sniffy counts the number of executed SQL queries and provides an API for validating them It is designed for unit tests and allows you to test if particular method doesn't make more than N SQL queries Especially it's useful to catch the ORM N+1 problem at early stages
public FilterRegistrationBean snifferFilter()
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
SnifferFilter filter = new SnifferFilter();
add sniffer: prefix to the JDBC connection url For example jdbc:h2:~/test should be changed to sniffer:jdbc:h2:mem:
URL must start with 'jdbc'
I managed to figure out the problem, Spring Boot makes extensive use of auto configuration and was trying to detect the
DatabaseDriver from the connection string. As the connection string no longer starts with
jdbc it was encountering a problem.
It was simply a case of specifying the
driver-class-name in my
application.yml rather than letting Spring Boot trying to auto detect it: