Spring-jdbc doesn't seem to work with spring-boot-starter
I am following the 15 minute tutorial for sprint-boot ( gs-relational-data-access )
So the tutorial works using an H2 database. So now I'm changing this to use DB2 by providing jars at runtime.
Changed build.gradle
dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-jdbc")
runtime fileTree(dir: 'libs', include: '*.jar')
//compile("com.h2database:h2")
testCompile("junit:junit")
}
The app is currently failing in complaints. JdbcTemplate bean definitions not found or something on string.
So now I have further modified build.gradle to comment out spring-jdbc and use spring-boot-starter-jdbc
dependencies {
compile("org.springframework.boot:spring-boot-starter-jdbc")
//compile("org.springframework:spring-jdbc")
runtime fileTree(dir: 'libs', include: '*.jar')
//compile("com.h2database:h2")
testCompile("junit:junit")
}
The app is now working again. I am curious to know why the spring-jdbc dependency is not working with just running a sprint run?
source to share
spring-jdbc
has all the classes supporting spring for the JDBC API but spring-boot-starter-jdbc
allows all the necessary configuration to be included. Thanks to auto-configuration, you can auto-detect JdbcTemplate
and JdbcOperations
with simple configuration in application.properties
source to share