PostgreSQL Dependency causes build time to EXPLODE upwards!

Why does including the ‘org.postgresql:postgresql:9.3-1102-jdbc41’ as a testCompile dependency make my project build time increase by 130 seconds or more?

In answer to the potential question as to why I picked the "testCompile"group, after reading the Gradle API documentation it stated the default behavior of the testCompile group is to include the dependency in the compile, runtime, and testRuntime groups, which is what I think I want. I need the JAR file at runtime for JDBC. Is the testCompile group an appropriate decision?

here is my build.gradle: buildscript {

ext {

springBootVersion = ‘1.1.8.RELEASE’


repositories {



dependencies {


} }

apply plugin: ‘java’ apply plugin: ‘eclipse’ apply plugin: ‘idea’ apply plugin: ‘spring-boot’

jar {

baseName = ‘report.api’

version = ‘0.0.1-SNAPSHOT’ } sourceCompatibility = 1.8 targetCompatibility = 1.8

repositories {

mavenCentral() }

dependencies {








testCompile(“org.springframework.boot:spring-boot-starter-test”) }

eclipse {

classpath {


containers ‘org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8’

} }

task wrapper(type: Wrapper) {

gradleVersion = ‘1.12’ }

If you need the PostgreSQL driver at application runtime then it should be added to the ‘runtime’ configuration, not ‘testRuntime’. If, however, PostgreSQL is only needed during test execution then ‘testRuntime’ is appropriate.

As far as build times increasing, try running your build with the ‘–profile’ flag. This will create a build execution report which should help identify which tasks in particular are taking a long time.

I appreciate the quick reply! I am looking up what it means to add it to my runtime configuration. Can you point me in the right direction?

You can look at the Gradle documentation for an overview of all the default configurations added by the java plugin.

By “add it to the runtime configuration” I mean change the following line from




Thanks for the clarification Mark.

As a follow up question, which I may repost, my runtime of the project increases by about 130 seconds after adding the PostgreSQL JDBC driver to the project. This is very strange and I’m not quite sure why this would happen. My project eventually runs and connects to a database though after taking up to five minutes at times.

Prior to adding “org.postgresql:postgresql:9.3-1102-jdbc41” to my dependencies my project would build in about five to ten seconds. After including the JDBC driver then my build and run times explode. Any clue as to why that would happen?

My only thought is it is something specific with Spring Data. My guess is it wasn’t actually attempting to configure and connect to a datasource without a JDBC driver on the classpath. Also, when you say your “build” is taking a long time, do you mean the build or just the Spring Boot startup. For example, do you see the delay when simply running ‘gradlew build’ or is this only when running the ‘bootRun’ task?

Interestingly enough I see the delay both when doing ‘./gradlew build’ as well as when running the ‘bootRun’ task. I profiled the task and found that it is my ‘test’ task that is taking so long.

My entire build took 1:35.39s and the test task took 1:34.81s. There are no active tests in my code that I am aware of. I had one before I commented its code out.

I, too, wondered if it is something with Spring Data. I have no idea how to determine whether that is the cause though. It would be nice to know what to look at next. It seems like the main option is to ask the Spring Data team if they could shed some light on the issue.

My guess is something is timing out, retrying, etc when attempting to construct a datasource connection. It is odd that it is doing that when running the test task despite you not having any tests declared. The Spring forums may be of better help, I’m quite certain this has nothing to do with Gradle specifically. Additionally, you might try cranking up the logging which might give you more insight specifically where in the Spring context initialization process your application is getting hung up on.

I’ll check into it. It is wasting HOURS of my time.

I found out that my testing task is what exploded.

I ended up excluding the test task whenever I built the project. The ballooning of the build time happened only after adding the JDBC driver to the dependencies, which causes me to think there is something unexpected behavior happening with the test task of Gradle and the JDBC driver.

Next I’ll have to try having a vanilla Gradle project and adding the JDBC driver as a runtime dependency to see if the same thing happens.

Do you still think it could be an issue with Spring Data? I have the same results whether I am connected to my VPN or not, which I have to be in order to get connected to my database.

If you change the configuration of the Postgres dependency from ‘testRuntime’ to ‘runtime’ and then run the ‘bootRun’ task do you still get the long build time?

Yes, I still get the long build time. I turned on Hibernate logging at the DEBUG level and found the reason the program is hanging. There is a statement that says “Unexpected error trying to gauge level of JDBC REF_CURSOR support : null” which I have no idea what that means yet. I already posted to the PostgreSQL bug mailing list, will be posting to the Hibernate forums, and will be posting a question to the StackOverflow Spring Boot tag.

The full log from ‘./gradlew bootRun’ to when the hanging starts is in this paste: